How to attach graph-tool to Django using Docker












1














I need to use some graph-tool calculations in my Django project. So I started with docker pull tiagopeixoto/graph-tool and then added it to my Docker-compose file:



version: '3'

services:

db:
image: postgres

graph-tool:
image: dcagatay/graph-tool

web:
build: .
command: python3 manage.py runserver 0.0.0.0:8000
volumes:
- .:/code
ports:
- "8000:8000"
depends_on:
- db
- graph-tool


When I up my docker-compose I got a line:



project_graph-tool_1_87e2d144b651 exited with code 0


And finally when my Django projects starts I can not import modules from graph-tool, like:



from graph_tool.all import *


If I try work directly in this docker image using:



docker run -it -u user -w /home/user tiagopeixoto/graph-tool ipython


everything goes fine.
What am I doing wrong and how can I fix it and finally attach graph-tool to Django? Thanks!










share|improve this question
























  • I see both build and image under graphtool. If you are using just the image, remove the build property.
    – Andrei Dumitrescu-Tudor
    Nov 21 at 7:12










  • @AndreiDumitrescu-Tudor removed, still exited with code 0, and ModuleNotFoundError: No module named 'graph_tool'
    – D. Make
    Nov 21 at 8:27
















1














I need to use some graph-tool calculations in my Django project. So I started with docker pull tiagopeixoto/graph-tool and then added it to my Docker-compose file:



version: '3'

services:

db:
image: postgres

graph-tool:
image: dcagatay/graph-tool

web:
build: .
command: python3 manage.py runserver 0.0.0.0:8000
volumes:
- .:/code
ports:
- "8000:8000"
depends_on:
- db
- graph-tool


When I up my docker-compose I got a line:



project_graph-tool_1_87e2d144b651 exited with code 0


And finally when my Django projects starts I can not import modules from graph-tool, like:



from graph_tool.all import *


If I try work directly in this docker image using:



docker run -it -u user -w /home/user tiagopeixoto/graph-tool ipython


everything goes fine.
What am I doing wrong and how can I fix it and finally attach graph-tool to Django? Thanks!










share|improve this question
























  • I see both build and image under graphtool. If you are using just the image, remove the build property.
    – Andrei Dumitrescu-Tudor
    Nov 21 at 7:12










  • @AndreiDumitrescu-Tudor removed, still exited with code 0, and ModuleNotFoundError: No module named 'graph_tool'
    – D. Make
    Nov 21 at 8:27














1












1








1


1





I need to use some graph-tool calculations in my Django project. So I started with docker pull tiagopeixoto/graph-tool and then added it to my Docker-compose file:



version: '3'

services:

db:
image: postgres

graph-tool:
image: dcagatay/graph-tool

web:
build: .
command: python3 manage.py runserver 0.0.0.0:8000
volumes:
- .:/code
ports:
- "8000:8000"
depends_on:
- db
- graph-tool


When I up my docker-compose I got a line:



project_graph-tool_1_87e2d144b651 exited with code 0


And finally when my Django projects starts I can not import modules from graph-tool, like:



from graph_tool.all import *


If I try work directly in this docker image using:



docker run -it -u user -w /home/user tiagopeixoto/graph-tool ipython


everything goes fine.
What am I doing wrong and how can I fix it and finally attach graph-tool to Django? Thanks!










share|improve this question















I need to use some graph-tool calculations in my Django project. So I started with docker pull tiagopeixoto/graph-tool and then added it to my Docker-compose file:



version: '3'

services:

db:
image: postgres

graph-tool:
image: dcagatay/graph-tool

web:
build: .
command: python3 manage.py runserver 0.0.0.0:8000
volumes:
- .:/code
ports:
- "8000:8000"
depends_on:
- db
- graph-tool


When I up my docker-compose I got a line:



project_graph-tool_1_87e2d144b651 exited with code 0


And finally when my Django projects starts I can not import modules from graph-tool, like:



from graph_tool.all import *


If I try work directly in this docker image using:



docker run -it -u user -w /home/user tiagopeixoto/graph-tool ipython


everything goes fine.
What am I doing wrong and how can I fix it and finally attach graph-tool to Django? Thanks!







django docker docker-compose graph-tool






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 21 at 8:27

























asked Nov 21 at 5:05









D. Make

9811




9811












  • I see both build and image under graphtool. If you are using just the image, remove the build property.
    – Andrei Dumitrescu-Tudor
    Nov 21 at 7:12










  • @AndreiDumitrescu-Tudor removed, still exited with code 0, and ModuleNotFoundError: No module named 'graph_tool'
    – D. Make
    Nov 21 at 8:27


















  • I see both build and image under graphtool. If you are using just the image, remove the build property.
    – Andrei Dumitrescu-Tudor
    Nov 21 at 7:12










  • @AndreiDumitrescu-Tudor removed, still exited with code 0, and ModuleNotFoundError: No module named 'graph_tool'
    – D. Make
    Nov 21 at 8:27
















I see both build and image under graphtool. If you are using just the image, remove the build property.
– Andrei Dumitrescu-Tudor
Nov 21 at 7:12




I see both build and image under graphtool. If you are using just the image, remove the build property.
– Andrei Dumitrescu-Tudor
Nov 21 at 7:12












@AndreiDumitrescu-Tudor removed, still exited with code 0, and ModuleNotFoundError: No module named 'graph_tool'
– D. Make
Nov 21 at 8:27




@AndreiDumitrescu-Tudor removed, still exited with code 0, and ModuleNotFoundError: No module named 'graph_tool'
– D. Make
Nov 21 at 8:27












1 Answer
1






active

oldest

votes


















2





+50









Rather than using a seperate docker image for graphtool, i think its better to use it within the same Dockerfile which you are using for Django. For example, update your current Dockerfile:



FROM ubuntu:16.04  # using ubuntu image

ENV PYTHONUNBUFFERED 1
ENV C_FORCE_ROOT true

# python3-graph-tool specific requirements for installation in Ubuntu from documentation
RUN echo "deb http://downloads.skewed.de/apt/xenial xenial universe" >> /etc/apt/sources.list &&
echo "deb-src http://downloads.skewed.de/apt/xenial xenial universe" >> /etc/apt/sources.list

RUN apt-key adv --keyserver pgp.skewed.de --recv-key 612DEFB798507F25

# Install dependencies
RUN apt-get update
&& apt-get install -y python3-pip python3-dev
&& apt-get install --yes --no-install-recommends --allow-unauthenticated python3-graph-tool
&& cd /usr/local/bin
&& ln -s /usr/bin/python3 python
&& pip3 install --upgrade pip

# Project specific setups
# These steps might be different in your project
RUN mkdir /code
WORKDIR /code
ADD . /code
RUN pip3 install -r requirements.pip


Now update your docker-compose file as well:



version: '3'
services:
db:
image: postgres
web:
build: .
container_name: djcon # <-- preferred over generated name
command: python3 manage.py runserver 0.0.0.0:8000
volumes:
- .:/code
ports:
- "8000:8000"
depends_on:
- db


Thats it. Now if you go to your web service's shell by docker exec -ti djcon bash(or any generated name instead of djcon), and access the django shell like this python manage.py shell. Then type from graph_tool.all import * and it will not throw any import error.






share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53405558%2fhow-to-attach-graph-tool-to-django-using-docker%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2





    +50









    Rather than using a seperate docker image for graphtool, i think its better to use it within the same Dockerfile which you are using for Django. For example, update your current Dockerfile:



    FROM ubuntu:16.04  # using ubuntu image

    ENV PYTHONUNBUFFERED 1
    ENV C_FORCE_ROOT true

    # python3-graph-tool specific requirements for installation in Ubuntu from documentation
    RUN echo "deb http://downloads.skewed.de/apt/xenial xenial universe" >> /etc/apt/sources.list &&
    echo "deb-src http://downloads.skewed.de/apt/xenial xenial universe" >> /etc/apt/sources.list

    RUN apt-key adv --keyserver pgp.skewed.de --recv-key 612DEFB798507F25

    # Install dependencies
    RUN apt-get update
    && apt-get install -y python3-pip python3-dev
    && apt-get install --yes --no-install-recommends --allow-unauthenticated python3-graph-tool
    && cd /usr/local/bin
    && ln -s /usr/bin/python3 python
    && pip3 install --upgrade pip

    # Project specific setups
    # These steps might be different in your project
    RUN mkdir /code
    WORKDIR /code
    ADD . /code
    RUN pip3 install -r requirements.pip


    Now update your docker-compose file as well:



    version: '3'
    services:
    db:
    image: postgres
    web:
    build: .
    container_name: djcon # <-- preferred over generated name
    command: python3 manage.py runserver 0.0.0.0:8000
    volumes:
    - .:/code
    ports:
    - "8000:8000"
    depends_on:
    - db


    Thats it. Now if you go to your web service's shell by docker exec -ti djcon bash(or any generated name instead of djcon), and access the django shell like this python manage.py shell. Then type from graph_tool.all import * and it will not throw any import error.






    share|improve this answer


























      2





      +50









      Rather than using a seperate docker image for graphtool, i think its better to use it within the same Dockerfile which you are using for Django. For example, update your current Dockerfile:



      FROM ubuntu:16.04  # using ubuntu image

      ENV PYTHONUNBUFFERED 1
      ENV C_FORCE_ROOT true

      # python3-graph-tool specific requirements for installation in Ubuntu from documentation
      RUN echo "deb http://downloads.skewed.de/apt/xenial xenial universe" >> /etc/apt/sources.list &&
      echo "deb-src http://downloads.skewed.de/apt/xenial xenial universe" >> /etc/apt/sources.list

      RUN apt-key adv --keyserver pgp.skewed.de --recv-key 612DEFB798507F25

      # Install dependencies
      RUN apt-get update
      && apt-get install -y python3-pip python3-dev
      && apt-get install --yes --no-install-recommends --allow-unauthenticated python3-graph-tool
      && cd /usr/local/bin
      && ln -s /usr/bin/python3 python
      && pip3 install --upgrade pip

      # Project specific setups
      # These steps might be different in your project
      RUN mkdir /code
      WORKDIR /code
      ADD . /code
      RUN pip3 install -r requirements.pip


      Now update your docker-compose file as well:



      version: '3'
      services:
      db:
      image: postgres
      web:
      build: .
      container_name: djcon # <-- preferred over generated name
      command: python3 manage.py runserver 0.0.0.0:8000
      volumes:
      - .:/code
      ports:
      - "8000:8000"
      depends_on:
      - db


      Thats it. Now if you go to your web service's shell by docker exec -ti djcon bash(or any generated name instead of djcon), and access the django shell like this python manage.py shell. Then type from graph_tool.all import * and it will not throw any import error.






      share|improve this answer
























        2





        +50







        2





        +50



        2




        +50




        Rather than using a seperate docker image for graphtool, i think its better to use it within the same Dockerfile which you are using for Django. For example, update your current Dockerfile:



        FROM ubuntu:16.04  # using ubuntu image

        ENV PYTHONUNBUFFERED 1
        ENV C_FORCE_ROOT true

        # python3-graph-tool specific requirements for installation in Ubuntu from documentation
        RUN echo "deb http://downloads.skewed.de/apt/xenial xenial universe" >> /etc/apt/sources.list &&
        echo "deb-src http://downloads.skewed.de/apt/xenial xenial universe" >> /etc/apt/sources.list

        RUN apt-key adv --keyserver pgp.skewed.de --recv-key 612DEFB798507F25

        # Install dependencies
        RUN apt-get update
        && apt-get install -y python3-pip python3-dev
        && apt-get install --yes --no-install-recommends --allow-unauthenticated python3-graph-tool
        && cd /usr/local/bin
        && ln -s /usr/bin/python3 python
        && pip3 install --upgrade pip

        # Project specific setups
        # These steps might be different in your project
        RUN mkdir /code
        WORKDIR /code
        ADD . /code
        RUN pip3 install -r requirements.pip


        Now update your docker-compose file as well:



        version: '3'
        services:
        db:
        image: postgres
        web:
        build: .
        container_name: djcon # <-- preferred over generated name
        command: python3 manage.py runserver 0.0.0.0:8000
        volumes:
        - .:/code
        ports:
        - "8000:8000"
        depends_on:
        - db


        Thats it. Now if you go to your web service's shell by docker exec -ti djcon bash(or any generated name instead of djcon), and access the django shell like this python manage.py shell. Then type from graph_tool.all import * and it will not throw any import error.






        share|improve this answer












        Rather than using a seperate docker image for graphtool, i think its better to use it within the same Dockerfile which you are using for Django. For example, update your current Dockerfile:



        FROM ubuntu:16.04  # using ubuntu image

        ENV PYTHONUNBUFFERED 1
        ENV C_FORCE_ROOT true

        # python3-graph-tool specific requirements for installation in Ubuntu from documentation
        RUN echo "deb http://downloads.skewed.de/apt/xenial xenial universe" >> /etc/apt/sources.list &&
        echo "deb-src http://downloads.skewed.de/apt/xenial xenial universe" >> /etc/apt/sources.list

        RUN apt-key adv --keyserver pgp.skewed.de --recv-key 612DEFB798507F25

        # Install dependencies
        RUN apt-get update
        && apt-get install -y python3-pip python3-dev
        && apt-get install --yes --no-install-recommends --allow-unauthenticated python3-graph-tool
        && cd /usr/local/bin
        && ln -s /usr/bin/python3 python
        && pip3 install --upgrade pip

        # Project specific setups
        # These steps might be different in your project
        RUN mkdir /code
        WORKDIR /code
        ADD . /code
        RUN pip3 install -r requirements.pip


        Now update your docker-compose file as well:



        version: '3'
        services:
        db:
        image: postgres
        web:
        build: .
        container_name: djcon # <-- preferred over generated name
        command: python3 manage.py runserver 0.0.0.0:8000
        volumes:
        - .:/code
        ports:
        - "8000:8000"
        depends_on:
        - db


        Thats it. Now if you go to your web service's shell by docker exec -ti djcon bash(or any generated name instead of djcon), and access the django shell like this python manage.py shell. Then type from graph_tool.all import * and it will not throw any import error.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 23 at 23:19









        ruddra

        11.4k32648




        11.4k32648






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53405558%2fhow-to-attach-graph-tool-to-django-using-docker%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            404 Error Contact Form 7 ajax form submitting

            How to know if a Active Directory user can login interactively

            TypeError: fit_transform() missing 1 required positional argument: 'X'