Home > database >  Pycharm "Cannot find reference" when OpenCV is in a venv python 3.10
Pycharm "Cannot find reference" when OpenCV is in a venv python 3.10

Time:10-15

EDIT- Things I tried

*enter image description here

Then I entered the new interpreter and added opencv-python (plus sign > searched for this > Install package): enter image description here

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.

enter image description here

If I switch interpreter to the regular one it recognizes the cv2 methods and autocomplete me.

CodePudding user response:

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:

  1. Uninstall both anaconda, pycharm (uninstall other pythons if you have them).

2. Create a new user with ascii only (e.g. Ben). In this user:

  1. Install anaconda (I guess miniconda will work too)
  2. Create a venv (I used this and this tutorials)
  3. Install your packages using conda-forge like in the tutorials
  • Related