Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pycharm run "Debugger speedups using cython" on docker hosted app

I have a strange issue that I can't seem to get to the bottom of. My django project is set up using docker-compose

version: '2'
services:
    db:
        image: postgres:9.6.0
        environment:
            POSTGRES_PASSWORD: docker
            POSTGRES_USER: docker
        ports:
            - "8001:5432"
    djweb:
        build: .
        command: python dj/manage.py runserver 0.0.0.0:8000
        volumes:
            - .:/code
        ports:
            - "8000:8000"
        depends_on:
            - db

and dockerfile is

 FROM python:3.5.2
 ENV PYTHONUNBUFFERED 1
 RUN mkdir /code
 WORKDIR /code
 ADD requirements.txt /code/
 RUN pip install -r requirements.txt
 ADD . /code/

In Pycharm I started a new Django project configured with docker compose and it was created just fine. When I try to debug it I get the usual:

warning: Debugger speedups using cython not found. Run '"/usr/local/bin/python" "/opt/.pycharm_helpers/pydev/setup_cython.py" build_ext --inplace' to build. pydev debugger: process 1 is connecting

And now the problem. I can't seem to be able to run that setup_cython command that Pycharm suggests on my 'djweb' container due to a strange read-only error. I would appreciate if anyone can point me in the right direction (I probably need to add some volume to my container or ??? - apparently pycharm also adds other images/containers alongside mine)

root@b8bf92996472:/# "/usr/local/bin/python" "/opt/.pycharm_helpers/pydev/setup_cython.py" build_ext --inplace
running build_ext building '_pydevd_bundle.pydevd_cython' extension creating build error: could not create 'build': Read-only file system

like image 225
Alexandru Cristian Avatar asked Nov 25 '16 16:11

Alexandru Cristian


1 Answers

I was running into the same problem and was able to solve it with a command this way:

docker run -t -i --volumes-from pycharm_helpers_PY-163.10154.50 IMAGE_NAME \
/usr/bin/python /opt/.pycharm_helpers/pydev/setup_cython.py build_ext --inplace

You would likely need to replace 163.10154.50 with your own instance - I found mine in PyCharm ->View->Tool Windows->Docker, in the view that pops up, under Docker->Containers.

IMAGE_NAME can be found with docker ps

Note - On my configuration I use docker-machine and need to run eval $(docker-machine env) from Terminal first.

like image 137
E Brake Avatar answered Oct 15 '22 21:10

E Brake