EDIT- Things I tried
*This question is the same, but the solutions there did not solve my problem. I didn't have a DLLs folder so I made one, tried both with and without deleting the file in site-packages/cv2/
*I checked this and this and couldn't make it work.
*I also tried to delete opencv-python
from my base interpreter and only download it on the venv, but still didn't work.
*I also tried to invalidate cache/ restart multiple times.
*I also tried to delete python and pycharm completely. When I upgraded to 3.10 I couldn't even install opencv. When I tried 3.8 again the same problem accoured.
I wanted to download ML libraries to Pycharm (python 3.8). Initially I just added them (e.g. opencv-python
) in the python interpreter itself (Settings > Project > Python interpreter) and it worked fine (So now my regular interpreter has a bunch of libraries on it).
Then I read it's better practice to make a new venv and download the libraries there. I created a new environment:
Then I entered the new interpreter and added opencv-python
(plus sign > searched for this > Install package):
After that I made a short script that needs cv2
. Pycharm couldn't import cv2, but the script runs correctly (displays the image) when "run" is pressed.
If I switch interpreter to the regular one it recognizes the cv2 methods and autocomplete me.
I solved it using anaconda
.
The first time I tried it didn't work, so it's probably a problem with having non-ascii username (again). I had the .conda
folder in a path which contained non-ascii, as well as the anaconda3 itself installed in a different place
To install it correctly:
2. Create a new user with ascii only (e.g. Ben). In this user: