Can not import cv2 correctly
binwan-dev opened this issue · 3 comments
binwan-dev commented
Blade6570 commented
Issue is here: microsoft/pylance-release#138
Now there are two solutions.
- compile the opencv from source
- If you have downloaded like pip install opencv-python then follow these two steps
- pip install mypy
- stubgen -m cv2 -o {cv2-package-folder} (In my case it is /home/soumya/anaconda3/lib/python3.7/site-packages/cv2)
I have tested the step 2 and it works.
steepestascent commented
I needed to modify the stubgen
command for this to work.
cd {to your cv2 directory}
stubgen -m cv2 -o .
mv cv2.pyi __init__.pyi
M-x lsp-restart-workspace
binwan-dev commented
It work, Thanks! I'll close this issue