skip to Main Content

I often use python in VScode. However, after two VScode updates, the import function (cv or numpy) is not working. I’ve tried using the shift+command+p and > python select interprete but none are working for these functions.

enter image description here

I tried use > pip install pylint but it didn’t work.

enter image description here

How can I solve this problem? Has someone the same problem in VScode?

2

Answers


  1. Steps I would suggest to follow:

    1. install the package again (cv2), even if it is installed.
    2. check vs code if it has any updates for the python extension.
    3. update vs code application.
    4. restart vs code.

    hope this helps.

    Login or Signup to reply.
  2. It is recommended to use a virtual environment to manage third-party packages and python versions more conveniently.

    1. Create a virtual environment with the following command

       python -m venv myenv
      

      enter image description here

    2. After the command is completed, select the virtual environment interpreter just created in the Select Interpreter panel

      enter image description here

    3. The new terminal can automatically activate the environment

      enter image description here

      enter image description here

    4. Now there is no package installed in the new virtual environment, and an error occurs

      enter image description here

    5. Install the cv2 package in the new environment, and the error disappeared after installing the package

      enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search