Home > front end >  VS code pyperclip Import "pyperclip" could not be resolved
VS code pyperclip Import "pyperclip" could not be resolved

Time:08-09

I am trying to use pyperclip for a python course I am doing and it tells me to import pyperclip, but when I import it VS code says Import "pyperclip" could not be resolved even though I went into the terminal and installed it my python version is 3.10.6 64bit does anyone know how to fix this?

pip install pyperclip

CodePudding user response:

Follow the steps below to choose an interpreter

  1. Open the command palette with Ctrl Shift P
  2. Search for Python:Select Interpreter
  3. Choose the correct interpreter

It is recommended to use a virtual environment

use the following command in the vscode terminal:

  • Create a virtual environment ( named .venv )

    python -m venv .venv
    
  • Activate the virtual environment

    .venv/Scripts/Activate
    
  • Select the interpreter in the virtual environment

  • Create a new terminal to automatically activate the virtual environment

  • Install the packages you need to use in the current environment

Virtual environments can help you manage using different python versions and using different packages.

  • Related