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.
6403 Discussions

Import cv2 error: undefined symbol: _ZNK6ngraph4Node9get_autobEv

simranS
Beginner
3,648 Views

Hi I am trying to inference inside openvino with Intel python distribution using the following Command, but it throws an cv2 error:

Openvino Version: 2021.1

Intel Python Distribution: Python 3.7.7 :: Intel Corporation

Error:

/opt/intel/openvino_2021/deployment_tools/inference_engine/samples/python/object_detection_sample_ssd$ python object_detection_sample_ssd.py -m /home/ubuntu/Documents/Simran/frozen_inference_graph.xml -i /home/ubuntu/Documents/Simran/images/images_2_134.jpg
Traceback (most recent call last):
File "object_detection_sample_ssd.py", line 21, in <module>
import cv2
ImportError: /opt/intel/openvino_2021/deployment_tools/inference_engine/lib/intel64/libinference_engine_transformations.so: undefined symbol: _ZNK6ngraph4Node9get_autobEv

 

I have tried the following links to resolve it but the issue still exists:

Kindly provide assistance.

Labels (1)
0 Kudos
8 Replies
Maksim_S_Intel
Employee
3,630 Views

It looks like wrong version of OpenCV is being loaded. Please check your environment, make sure PYTHONPATH and LD_LIBRARY_PATH are set correctly.

0 Kudos
simranS
Beginner
3,624 Views

I have switched now to openvino version 2019R3 and the error now is :

Traceback (most recent call last):
File "object_detection_sample_ssd.py", line 21, in <module>
import cv2
ImportError: No module named cv2

My OpenCV version is 3.4.2

What should be the correct PYTHONPATH and LD_LIBRARY PATH? The output of the existing paths are shown below:

echo $PYTHONPATH

 /opt/intel/openvino_2019.3.376/python/python3.6:/opt/intel/openvino_2019.3.376/python/python3:/opt/intel/openvino_2019.3.376/deployment_tools/open_model_zoo/tools/accuracy_checker:/opt/intel/openvino_2019.3.376/deployment_tools/model_optimizer:

echo $LD_LIBRARY_PATH

/home/ubuntu/Downloads/intelpython3/lib/libfabric:/opt/intel/openvino_2019.3.376/opencv/lib:/opt/intel/opencl:/opt/intel/openvino_2019.3.376/deployment_tools/inference_engine/external/hddl/lib:/opt/intel/openvino_2019.3.376/deployment_tools/inference_engine/external/gna/lib:/opt/intel/openvino_2019.3.376/deployment_tools/inference_engine/external/mkltiny_lnx/lib:/opt/intel/openvino_2019.3.376/deployment_tools/inference_engine/external/tbb/lib:/opt/intel/openvino_2019.3.376/deployment_tools/inference_engine/lib/intel64:/opt/intel/openvino_2019.3.376/openvx/lib:

 

0 Kudos
Maksim_S_Intel
Employee
3,619 Views

Since you are using OpenVINO 2021 your PYTHONPATH should contain "/opt/intel/openvino_2021/python/python3" and LD_LIBRARY_PATH should contain "/opt/intel/openvino_2021/opencv/lib". These variables are set by the "/opt/intel/openvino_2021/bin/setupvars.sh" script. See https://docs.openvinotoolkit.org/latest/openvino_docs_install_guides_installing_openvino_linux.html#set-the-environment-variables for details.

0 Kudos
IntelSupport
Moderator
3,595 Views

Hi SimranS,

 

It might cause by the OpenVINO environment is set with the correct version. Since you have other versions of OpenVINO installed on your machine, please make sure you are setting the OpenVINO environment according to the version carefully. It is important to set the correct environment variables exactly for the 2021.1 builds.

Also, please ensure you carefully followed all the additional installation steps from the OpenVINO website.

https://docs.openvinotoolkit.org/2021.1/openvino_docs_install_guides_installing_openvino_linux.html#additional-NCS-steps

 

Regards,

Aznie


0 Kudos
simranS
Beginner
3,578 Views

Hi, 

I have checked the PYTHONPATH and LD_LIBRARY_PATH, seem correct.

(base) ubuntu@ubuntu:~/Downloads/intelpython3$ echo $PYTHONPATH
/opt/intel/openvino_2019.3.376/python/python3.6:/opt/intel/openvino_2019.3.376/python/python3:/opt/intel/openvino_2019.3.376/deployment_tools/open_model_zoo/tools/accuracy_checker:/opt/intel/openvino_2019.3.376/deployment_tools/model_optimizer:


(base) ubuntu@ubuntu:~/Downloads/intelpython3$ echo $LD_LIBRARY_PATH
/home/ubuntu/Downloads/intelpython3/lib/libfabric:/opt/intel/openvino_2019.3.376/opencv/lib:/opt/intel/opencl:/opt/intel/openvino_2019.3.376/deployment_tools/inference_engine/external/hddl/lib:/opt/intel/openvino_2019.3.376/deployment_tools/inference_engine/external/gna/lib:/opt/intel/openvino_2019.3.376/deployment_tools/inference_engine/external/mkltiny_lnx/lib:/opt/intel/openvino_2019.3.376/deployment_tools/inference_engine/external/tbb/lib:/opt/intel/openvino_2019.3.376/deployment_tools/inference_engine/lib/intel64:/opt/intel/openvino_2019.3.376/openvx/lib:

This cv import error only arises inside Intel python distribution environment when I try to run inference engine.

(base) ubuntu@ubuntu:/opt/intel/openvino_2019.3.376/deployment_tools/inference_engine/samples/python_samples/object_detection_sample_ssd$ sudo python object_detection_sample_ssd.py -m /home/ubuntu/Downloads/frozen_inference_graph.xml -i /home/ubuntu/Downloads/images/pics_1_124.jpg
Traceback (most recent call last):
File "object_detection_sample_ssd.py", line 21, in <module>
import cv2
ImportError: No module named cv2

 

Where as importing cv2 inside python shell doesnot give any error:

(base) ubuntu@ubuntu:~/Downloads/intelpython3$ python
Python 3.7.7 (default, Sep 11 2020, 20:43:12)
[GCC 7.3.0] :: Intel Corporation on linux
Type "help", "copyright", "credits" or "license" for more information.
Intel(R) Distribution for Python is brought to you by Intel Corporation.
Please check out: https://software.intel.com/en-us/python-distribution
>>> import cv2
>>>

Also attached screenshots for the same.

0 Kudos
Maksim_S_Intel
Employee
3,572 Views

Running python with sudo does not preserve environment, try "sudo -E"  (see https://linux.die.net/man/8/sudo).  On some platforms "sudo" can drop LD_LIBRARY_PATH even with "-E" option for security reasons (see https://superuser.com/questions/544518/sudo-e-not-passing-all-variables).

Are you sure you need "sudo"? All samples should be able to run with regular user privilege level.

0 Kudos
IntelSupport
Moderator
3,568 Views

Hi,

I noticed from your $PYTHONPATH, it shows that you have the Python 3.6 version. If you are running the OpenVINO inference engine using Python 3.6, please make sure you have installed the OpenCV for Python 3.6 in the OpenVINO environment.

 

Refer to this OpenVINO installation steps carefully from the following link. https://docs.openvinotoolkit.org/latest/openvino_docs_install_guides_installing_openvino_linux.html

 

Regards,

Aznie


0 Kudos
IntelSupport
Moderator
3,503 Views

Hi SimranS,

This thread will no longer be monitored since we have provided a solution. If you need any additional information from Intel, please submit a new question.


Regards,

Aznie


0 Kudos
Reply