Reputation: 561
When I run python script by command sudo python script.py
I get error in the line
from openvino.inference_engine import IENetwork, IECore
The error is
ImportError: No module named openvino.inference_engine
But When I open the python shell and run
from openvino.inference_engine import IENetwork, IECore
I don't get this error.
What is the reason for the difference and how to fix this error?
Upvotes: 4
Views: 7886
Reputation: 2174
The issue you are facing is because the inference engine path is not found in the path variable. In openvino the path variables such as the path to openvino inference engine are setup for user by running the setupvars.sh shell script in the below path:
intel/openvino_2019.1.144/bin/setupvars.sh
The path variables are set specific to the user and are not present in the path variable for the sudo user. So when you run the python script using "sudo python script.py
" you get the module not found error as the path variables for openvino are not rightly set for sudo.
If you open the setupvars.sh you can see all path variable are set without sudo like the below example
export PATH=~/intel/openvino_2019.2.242/python/python3.7:$PATH
**
** To resolve your error you can use any of the two below alternatives:
1)You can run "python script.py
" which could give you your expected result.
2)If you want to get this packages in "sudo python script.py
" you must add openvino path to the sudo path. This can be done by editing the setupvars.sh file by changing the commands used to set paths as in the below example
eg:
export PATH=~/intel/openvino_2019.2.242/python/python3.7:$PATH
should be replaced with
sudo PATH=~/intel/openvino_2019.2.242/python/python3.7:$PATH
Upvotes: 2