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.

Python can't find the mvnc Module

idata
Employee
3,382 Views

I've been trying to setup the movidius library created by intel, but I keep getting stuck when I try to import the mvnc package.

 

To set up mvnc I followed the directions here: https://www.pyimagesearch.com/2018/02/19/real-time-object-detection-on-the-raspberry-pi-with-the-movidius-ncs/

 

and when it comes time to test if the install works, I run

 

 

make examples

 

 

which gives this error whenever I run it.

 

Traceback (most recent call last): File "/usr/local/bin/mvNCCompile", line 25, in <module> from Models.Blob import * File "/usr/local/bin/ncsdk/Models/Blob.py", line 19, in <module> from Controllers.MiscIO import * File "/usr/local/bin/ncsdk/Controllers/MiscIO.py", line 35, in <module> from mvnc import mvncapi

 

So I'm wondering how it would be possible to get python to recognize the mvnc module so I can import it into any of my code. Thank you for your help!

 

I'm running Ubuntu 18.04.1 LTS in a virtual machine on a windows 10 computer

 

Here's the full command line output:

 

./install-opencv.sh Installing opencv python for non-Raspbian [sudo] password for odyssey: Requirement already satisfied: opencv-python in /usr/local/lib/python3.6/dist-packages Requirement already satisfied: numpy>=1.11.3 in /usr/lib/python3/dist-packages (from opencv-python) Requirement already satisfied: opencv-contrib-python in /usr/local/lib/python3.6/dist-packages Requirement already satisfied: numpy>=1.11.3 in /usr/lib/python3/dist-packages (from opencv-contrib-python) make examples starting. (cd examples; make) make[1]: Entering directory '/home/odyssey/workspace/ncsdk/examples' make -C apps/. make[2]: Entering directory '/home/odyssey/workspace/ncsdk/examples/apps' make -C hello_ncs_py/. make[3]: Entering directory '/home/odyssey/workspace/ncsdk/examples/apps/hello_ncs_py' nothing to make, use 'make run' to run. make[3]: Leaving directory '/home/odyssey/workspace/ncsdk/examples/apps/hello_ncs_py' make -C multistick_cpp/. make[3]: Entering directory '/home/odyssey/workspace/ncsdk/examples/apps/multistick_cpp' making googlenet (cd ../../caffe/GoogLeNet; make compile; cd ../../apps/multistick_cpp; cp ../../caffe/GoogLeNet/graph ./googlenet.graph;) make[4]: Entering directory '/home/odyssey/workspace/ncsdk/examples/caffe/GoogLeNet' making prereqs (cd ../../data/ilsvrc12; make) make[5]: Entering directory '/home/odyssey/workspace/ncsdk/examples/data/ilsvrc12' make[5]: Leaving directory '/home/odyssey/workspace/ncsdk/examples/data/ilsvrc12' making prototxt Prototxt file already exists making caffemodel caffemodel file already exists making compile mvNCCompile -w bvlc_googlenet.caffemodel -s 12 deploy.prototxt Traceback (most recent call last): File "/usr/local/bin/mvNCCompile", line 25, in <module> from Models.Blob import * File "/usr/local/bin/ncsdk/Models/Blob.py", line 19, in <module> from Controllers.MiscIO import * File "/usr/local/bin/ncsdk/Controllers/MiscIO.py", line 35, in <module> from mvnc import mvncapi ModuleNotFoundError: No module named 'mvnc' Makefile:80: recipe for target 'compile' failed make[4]: *** [compile] Error 1 make[4]: Leaving directory '/home/odyssey/workspace/ncsdk/examples/caffe/GoogLeNet' cp: cannot stat '../../caffe/GoogLeNet/graph': No such file or directory Makefile:9: recipe for target 'googlenet' failed make[3]: *** [googlenet] Error 1 make[3]: Leaving directory '/home/odyssey/workspace/ncsdk/examples/apps/multistick_cpp' Makefile:12: recipe for target 'multistick_cpp/.' failed make[2]: *** [multistick_cpp/.] Error 2 make[2]: Leaving directory '/home/odyssey/workspace/ncsdk/examples/apps' Makefile:12: recipe for target 'apps/.' failed make[1]: *** [apps/.] Error 2 make[1]: Leaving directory '/home/odyssey/workspace/ncsdk/examples' Makefile:57: recipe for target 'examples' failed make: *** [examples] Error 2
0 Kudos
20 Replies
idata
Employee
2,489 Views

@Cynopolis Were you able to install the NCSDK successfully? Can you post the install log here? After a successful installation, make sure you run make examples in a new terminal window so that the pythonpath is set. You can check the pythonpath after installation by opening a new terminal window and typing in the following command: echo $PYTHONPATH

0 Kudos
idata
Employee
2,489 Views

Sure, I added a link to the install log because it's too long to just paste in. The install did go successfully.

 

and this is the output I get when I run echo $PYTHONPATH

 

:/opt/movidius/caffe/python

 

Here's the link to the install log:

 

https://drive.google.com/open?id=1q2FmC9aB2h_wvS8FiGnBV7kFE88RNdo9
0 Kudos
idata
Employee
2,489 Views

@Cynopolis Okay it looks like your install was successful. Can you do me a favor and go into one of the example folders like AgeNet, GenderNet or SqueezeNet and type in the command make run and see if it is able to run correctly? Thanks.

0 Kudos
idata
Employee
2,489 Views
making prereqs (cd ../../data/ilsvrc12; make) make[1]: Entering directory '/home/odyssey/workspace/ncsdk/examples/data/ilsvrc12' make[1]: Leaving directory '/home/odyssey/workspace/ncsdk/examples/data/ilsvrc12' making prototxt Prototxt file already exists making caffemodel caffemodel file already exists making compile mvNCCompile -w bvlc_googlenet.caffemodel -s 12 deploy.prototxt Traceback (most recent call last): File "/usr/local/bin/mvNCCompile", line 25, in <module> from Models.Blob import * File "/usr/local/bin/ncsdk/Models/Blob.py", line 19, in <module> from Controllers.MiscIO import * File "/usr/local/bin/ncsdk/Controllers/MiscIO.py", line 35, in <module> from mvnc import mvncapi ModuleNotFoundError: No module named 'mvnc' Makefile:80: recipe for target 'compile' failed make: *** [compile] Error 1

 

That's the error I get when I try to run GoogLeNet, I also tried both AlexNet and SqueezeNet and I get the same problem.

0 Kudos
idata
Employee
2,489 Views

Does anyone know how I could solve this problem? I'm thinking python doesn't know where the mvncapi.py file is, so is there a way to point it to that file?

0 Kudos
idata
Employee
2,489 Views

@Cynopolis

 

How is your environment variable registered?

 

$ sudo find / -name mvncapi.py /usr/local/lib/python3.5/dist-packages/mvnc/mvncapi.py /usr/local/lib/python2.7/dist-packages/mvnc/mvncapi.py /home/xxxx/ncsdk/api/python/mvnc/mvncapi.py /opt/movidius/NCSDK/ncsdk-armv7l/api/python/mvnc/mvncapi.py /opt/movidius/NCSDK/ncsdk-x86_64/api/python/mvnc/mvncapi.py

 

Below is mine.

 

$ echo $PYTHONPATH :/opt/movidius/caffe/python:/usr/local/lib

 

If "/usr/local/lib" is not displayed, the environment is wrong.

0 Kudos
idata
Employee
2,489 Views

Here's my out put for

 

sudo find / -name mvncapi.py [sudo] password for odyssey: /home/odyssey/.local/share/Trash/files/workspace/ncsdk/api/python/mvnc/mvncapi.py /home/odyssey/workspace/ncsdk/api/python/mvnc/mvncapi.py /home/odyssey/workspace/mvncsdk/ncsdk-1.12.00.01/api/python/mvnc/mvncapi.py find: ‘/run/user/1000/gvfs’: Permission denied /opt/movidius/NCSDK/ncsdk-armv7l/api/python/mvnc/mvncapi.py /opt/movidius/NCSDK/ncsdk-x86_64/api/python/mvnc/mvncapi.py /usr/local/lib/python3.6/dist-packages/mvnc/mvncapi.py /usr/local/lib/python2.7/dist-packages/mvnc/mvncapi.py

 

and here's my output for

 

echo $PYTHONPATH :/opt/movidius/caffe/python

 

as you can see "usr/local/lib" isn't there, is there a way to fix that?

0 Kudos
idata
Employee
2,489 Views

@Cynopolis

 

$ export PYTHONPATH=$PYTHONPATH:/usr/local/lib:/usr/local/lib/python3.6/dist-packages/mvnc
0 Kudos
idata
Employee
2,489 Views

I ran that command and now my python path looks like:

 

echo $PYTHONPATH :/opt/movidius/caffe/python:/usr/local/lib:/usr/local/lib/python3.6/dist-packages/mvnc

 

but I ran make examples, and still got the same error:

 

./install-opencv.sh Installing opencv python for non-Raspbian [sudo] password for odyssey: Requirement already satisfied: opencv-python in /usr/local/lib/python3.6/dist-packages Requirement already satisfied: numpy>=1.11.3 in /usr/lib/python3/dist-packages (from opencv-python) Requirement already satisfied: opencv-contrib-python in /usr/local/lib/python3.6/dist-packages Requirement already satisfied: numpy>=1.11.3 in /usr/lib/python3/dist-packages (from opencv-contrib-python) make examples starting. (cd examples; make) make[1]: Entering directory '/home/odyssey/workspace/ncsdk/examples' make -C apps/. make[2]: Entering directory '/home/odyssey/workspace/ncsdk/examples/apps' make -C hello_ncs_py/. make[3]: Entering directory '/home/odyssey/workspace/ncsdk/examples/apps/hello_ncs_py' nothing to make, use 'make run' to run. make[3]: Leaving directory '/home/odyssey/workspace/ncsdk/examples/apps/hello_ncs_py' make -C multistick_cpp/. make[3]: Entering directory '/home/odyssey/workspace/ncsdk/examples/apps/multistick_cpp' making googlenet (cd ../../caffe/GoogLeNet; make compile; cd ../../apps/multistick_cpp; cp ../../caffe/GoogLeNet/graph ./googlenet.graph;) make[4]: Entering directory '/home/odyssey/workspace/ncsdk/examples/caffe/GoogLeNet' making prereqs (cd ../../data/ilsvrc12; make) make[5]: Entering directory '/home/odyssey/workspace/ncsdk/examples/data/ilsvrc12' make[5]: Leaving directory '/home/odyssey/workspace/ncsdk/examples/data/ilsvrc12' making prototxt Prototxt file already exists making caffemodel caffemodel file already exists making compile mvNCCompile -w bvlc_googlenet.caffemodel -s 12 deploy.prototxt Traceback (most recent call last): File "/usr/local/bin/mvNCCompile", line 25, in <module> from Models.Blob import * File "/usr/local/bin/ncsdk/Models/Blob.py", line 19, in <module> from Controllers.MiscIO import * File "/usr/local/bin/ncsdk/Controllers/MiscIO.py", line 35, in <module> from mvnc import mvncapi ImportError: cannot import name 'mvncapi' Makefile:80: recipe for target 'compile' failed make[4]: *** [compile] Error 1 make[4]: Leaving directory '/home/odyssey/workspace/ncsdk/examples/caffe/GoogLeNet' cp: cannot stat '../../caffe/GoogLeNet/graph': No such file or directory Makefile:9: recipe for target 'googlenet' failed make[3]: *** [googlenet] Error 1 make[3]: Leaving directory '/home/odyssey/workspace/ncsdk/examples/apps/multistick_cpp' Makefile:12: recipe for target 'multistick_cpp/.' failed make[2]: *** [multistick_cpp/.] Error 2 make[2]: Leaving directory '/home/odyssey/workspace/ncsdk/examples/apps' Makefile:12: recipe for target 'apps/.' failed make[1]: *** [apps/.] Error 2 make[1]: Leaving directory '/home/odyssey/workspace/ncsdk/examples' Makefile:57: recipe for target 'examples' failed make: *** [examples] Error 2
0 Kudos
idata
Employee
2,489 Views

@Cynopolis Maybe your bash .profile file isn't loading your .bashrc file. https://askubuntu.com/questions/161249/bashrc-not-executed-when-opening-new-terminal

0 Kudos
idata
Employee
2,489 Views

I checked to see if both .bashrc and .profile existed in my home folder, and they do. By the looks of it, the .profile script is correctly locating the .bachrc file and loading it. Here's that code:

 

# if running bash if [ -n "$BASH_VERSION" ]; then # include .bashrc if it exists if [ -f "$HOME/.bashrc" ]; then . "$HOME/.bashrc" fi fi
0 Kudos
idata
Employee
2,489 Views

@Cynopolis It could be related to line endings depending on how you got the NCSDK. I recommend removing and re-downloading the NCSDK. Try the following steps:

 

     

  1. Uninstall your current NCSDK by using the uninstall.sh script in the ncsdk folder.
  2.  

  3. Delete your current NCSDK folder.
  4.  

  5. Get a new copy of the NCSDK files using the command: wget https://ncs-forum-uploads.s3.amazonaws.com/ncsdk/ncsdk-01_12_00_01-full/ncsdk-1.12.00.01.tar.gz
  6.  

  7. Extract the files using the command tar xvf ncsdk-1.12.00.01.tar.gz
  8.  

  9. Install the NCSDK by typing in cd ncsdk-1.12.00.01 and then make install
  10.  

  11. Afterwards, try typing in the command: make examples
  12.  

 

Let me know if this works for you.

0 Kudos
idata
Employee
2,489 Views

I have the same issue but have been waiting for a reply.

 

Isn't this going back to version 1 of the SDK? Not version 2?
0 Kudos
idata
Employee
2,489 Views

I am also facing the exact problem. Make install successful but make examples failed. I tried several ways to make it run. None of the ways is working!

0 Kudos
idata
Employee
2,489 Views

@mthakkar Hi, have you tried going through each of the steps I listed above to see if they work for you? Please try each step even if it seems redundant and I'd appreciate it if you could let me know if it works/doesn't work. Thanks.

 

@chicagobob123 Yeah, this was for NCSDK v1.12 as that is the version being installed by Cynopolis. If NCSDK v2.05 is desired, you can just replace the wget command with: wget https://ncs-forum-uploads.s3.amazonaws.com/ncsdk/ncsdk-02_05_00_02-full/ncsdk-2.05.00.02.tar.gz

0 Kudos
idata
Employee
2,489 Views

I will try and reinstall the thing from scratch this asap. Let you know.

 

Something is going on. I traced the path down and there was no mnvc anything to compile anything.

 

Not sure whats going on. The installations seem more unstable now than ever.
0 Kudos
idata
Employee
2,489 Views

@chicagobob123 I just tried installing NCSDK 2.05.00.02 on a fresh machine and using steps 3-6 (but for ncsdk 2.05) from above and I didn't have any issues. This was on an HP Envy laptop running Ubuntu 16.04.

 

     

  1. Get a new copy of the NCSDK files using the command: wget https://ncs-forum-uploads.s3.amazonaws.com/ncsdk/ncsdk-02_05_00_02-full/ncsdk-2.05.00.02.tar.gz
  2.  

  3. Extract the files using the command tar xvf ncsdk-2.05.00.02.tar.gz
  4.  

  5. Install the NCSDK by typing in cd ncsdk-2.05.00.02 and then make install
  6.  

  7. Afterwards, plug your NCS device into your machine and try typing in the command make examples
  8.  

0 Kudos
idata
Employee
2,489 Views

I got through this and it seems to work. You had the instructions down pretty good except you didn't mention I needed the stick plugged in to build. I know it should have been a given, just saying that it needs to be plugged in. Now back to getting my Pi working again.

0 Kudos
idata
Employee
2,489 Views

@chicagobob123 I'll make the edit. Thanks.

0 Kudos
idata
Employee
2,043 Views

I installed SDK at an Ubuntu 16.04 lattepanda with intel processor. Initially MVNC did not import, after this I tried with sudo, then it worked. Since this, I can only run it with sudo. It has not been a problem since then, but trying to run the examples, the caffe library cannot be imported. it shows that caffe is not installed with sudo, without sudo it shows the following error: ImportError: /opt/movidius/ssd-caffe/build/lib/libcaffe.so.1.0.0-rc3: undefined symbol: _ZN6google4base21CheckOpMessageBuilder9NewStringB5cxx11Ev

 

I did a fresh installation of the movidius SDK and caffe, but the problem persist.

0 Kudos
Reply