How to import cv2 module in Pycharm?

Hello.

Today I installed openCV2.4 (and module cv2).
I can import cv2 when I use python from terminal, but I imported cv2 and run on Pycharm,  an error occurred “no module named cv2”.
When I use Pycharm(or .py scripts), Should I make any special settings for import newly installed module?
0
9 comments
Avatar
Permanently deleted user

I am also getting the same error, "No module name cv2". Please help

0
Avatar
Permanently deleted user

me too, i don't know how to do.

 

0
Avatar
Permanently deleted user

me too, i managed to install open cv but unable to use it in pycharm. plz help

0
Avatar
Permanently deleted user

In my case I thought I had the same issue too, after installing it it can't resolve anything about the module:

but if I actually hit run anyway it works, maybe it has issue to autocomplete because opencv really comes as a compiled library (and for performace reason it makes sense) and doesn't have many python files, I found this comment related to a windows installation:

http://stackoverflow.com/questions/18672087/autocomplete-for-opencv-python-in-windows-not-working

and checking my installation this is what I found:

 

2
Avatar
Permanently deleted user

Hi~I can find where the `cv2.cpython-36m-darwin.so` locate, but I don't get a folder named **cv2** on the file path

Where can I find it?

0
Avatar
Permanently deleted user

has anyone find how to fix that problem? i am having the same issue....

0
Avatar
Permanently deleted user

You must choose correct "Project interpreter" in project settings (PyCharm IDE). If you have already installed Open CV on virtualenv, you must choose this virtual interpreter in settings too.

1
Avatar
Permanently deleted user

This answer is 100% wrong, people keep answering the same question with the same answer and it's so obvious that they've not even tried to do this themselves.

0
Avatar
Permanently deleted user

windows

//If cannot import name 'cv2'
C:\Program Files\Python35\Lib\site-packages\cv2\cv2.cp35-win_amd64.pyd (it is a dll)
copy to
C:\Program Files\JetBrains\PyCharm 2019.x.x\helpers\pydev

 

linux

//If cannot import name 'cv2'
/usr/local/lib/python3.5/dist-packages/cv2/cv2.cpython-35m-x86_64-linux-gnu.so
copy to
/opt/pycharm-2019.x.x/helpers/pydev/cv2.cpython-35m-x86_64-linux-gnu.so

.so lib path
Run > Edit Configurations:
[Environment Variables]
add
LD_LIBRARY_PATH=/usr/local/lib/python3.5/dist-packages/cv2/.libs

will be done and ok
I try this, use almost 24 hours   by Jesse Stone

0

Please sign in to leave a comment.