How to import OpenCV library in PyCharm by self-building

asked 2019-11-17 23:37:31 -0600

cv_new gravatar image

I built the OpenCV4 by Cmake and installed the opecv4.0 using anaconda3 and its python3.7. My platform is Ubuntu 18.04 LTS. I can successfully use the OpenCV in terminal. But the PyCharm's project interpreter cannot find the opencv library, so I cannot use the import cv2 in my file.

I tried to rename the to and then copy to the folder "/home/user/anaconda/lib/python3.7/site/package", but I still cannot see the opencv library in the PyCharm's project interpreter using the anaconda python interpreter and also cannot use the opencv library.

Because I built the OpenCV 4.0 by Cmake, I didn't install the anaconda's opencv library using conda command.

In PyCharm, I added the "/home/user/anaconda/lib/python3.7/site/package" to the "Add content root" in the "file–>setting–>project:server–>project structure", but it didn't fix my problem.

Please help. Thanks.

edit retag flag offensive close merge delete



how to configure that is probably way off here

I built the OpenCV4 by Cmake and installed the opecv4.0 using anaconda3

now you have 2 versions (bad !!!!), and none fits ?

berak gravatar imageberak ( 2019-11-18 00:51:35 -0600 )edit

Sorry, I make you misunderstood. I install the opencv4 by cmake using the anaconda's python 3.7. Now, I found the problem, as I set the python3 package path as "lib/python3.7/site-packages". It should be "/home/user/anaconda3/lib/python3.7/site-packages". Therefore, I rebuild again. But I face another problem.

cv_new gravatar imagecv_new ( 2019-11-18 07:02:33 -0600 )edit

ah, ok, thanks for the clarification ;)

berak gravatar imageberak ( 2019-11-18 07:05:02 -0600 )edit