markus-hinsche
markus-hinsche

Reputation: 1422

PyCharm does not find python dependency when using Docker interpreter

I wrote a Dockerfile. When I build the image, start a container, and go to the python console, I can access certain python dependencies (rospy in my case).

When I configure the docker image as a Interpreter in PyCharm, it does not find these dependencies.

Upvotes: 2

Views: 823

Answers (1)

markus-hinsche
markus-hinsche

Reputation: 1422

I found the following: When I am in the container, I found what the PYTHONPATH is.

root@12b39bdd7ea9:/src# echo $PYTHONPATH
/opt/ros/melodic/lib/python2.7/dist-packages:

I add this PYTHONPATH to my Dockerfile:

FROM ros:melodic
<other stuff>
ENV PYTHONPATH="/opt/ros/melodic/lib/python2.7/dist-packages/:$PYTHONPATH"

Now PyCharm also finds the dependencies, e.g., rospy.

Upvotes: 1

Related Questions