Intel® Distribution of OpenVINO™ Toolkit
Community assistance about the Intel® Distribution of OpenVINO™ toolkit, OpenCV, and all aspects of computer vision-related on Intel® platforms.
6392 Discussions

Python can't find caffe when started with "docker exec"

idata
Employee
1,238 Views

I have a running container with python and pycaffe in it. If I use docker exec to enter via a bash, I can the run a python script that imports the caffe module. But it fails when using this command:

 

docker exec -ti dts bash -c "python /root/init_random_weights.py"

 

mroos@synapse:scratch$ docker exec -ti dts bash -c "python /root/init_random_weights.py" Hello Traceback (most recent call last): File "/root/init_random_weights.py", line 4, in <module> import caffe ImportError: No module named caffe

 

Why isn't python finding caffe when called in this manner? My .bashrc on the running container adds caffe to PYTHONPATH:

 

export PYTHONPATH=/usr/local/caffe/python:

 

What am I misunderstanding here?

0 Kudos
2 Replies
idata
Employee
802 Views

Thanks to some info here: https://docs.docker.com/engine/reference/commandline/exec/, I implemented a workaround by defining the PYTHONPATH env variable in the docker exec call as such:

 

docker exec -ti -w /root -e PYTHONPATH=/usr/local/caffe/python: dts bash -c "python /root/init_random_weights.py"

 

But I still don't understand why, in the absence of the -e option, the PYTHONPATH of my host machine is used rather than the PYTHONPATH of the .bashrc file in the container.

0 Kudos
idata
Employee
802 Views

@mattroos How did you build your docker container/image? There are some instructions for NCSDK 2 at https://movidius.github.io/ncsdk/docker.html.

0 Kudos
Reply