Steely
Steely

Reputation: 720

PyCharm Remote Interpreter: Cannot Execute Docker's Python Binary

I have configured PyCharm to target the Python binary in my Docker container, but am getting this error:

Couldn't refresh skeletons for remote interpreter
failed to run generator3.py for docker://app:latest//usr/local/python/bin/python, exit code 126, stderr: ----- /usr/local/python/bin/python: /usr/local/python/bin/python: cannot execute binary file -----

Running PyCharm 5.0.4 with Docker 1.10.0 in a VM with Python 3.4.3.

Here are my PyCharm Remote Interpreter settings: enter image description here

Saving those settings gives a Non-zero exit code. and the above error.

Upvotes: 4

Views: 4686

Answers (2)

Steely
Steely

Reputation: 720

The problem was that I was using Docker Compose before PyCharm fully supported it, which didn't really start to happen until PyCharm 2016.1. The PyCharm blog posted about how to use it with Docker Compose about a month after I asked this question.

Upvotes: 0

Tim
Tim

Reputation: 1433

In the Dockerfile of your docker image you will probably find an ENTRYPOINT ["bash"] or similar. PyCharm will try to run the interpreter like so :

docker run app:latest /usr/local/python/bin/python

In combination with the ENTRYPOINT that results in the following command within the container:

bash /usr/local/python/bin/python

From that the error message makes sense. If you have control over the Dockerfile you can either change the ENTRYPOINT to CMD or - if that's not an option for you - change the entrypoint so that it can work with /usr/local/python/bin/python as parameter and do the right thing with it.

Upvotes: 5

Related Questions