0

I've installed pyperclip and it works fine in python IDLE yet when I try to open the same program in vscode I get : ModuleNotFoundError: No module named 'pyperclip'. I'm on Python 3.10.0 and pyperclip is version 1.8.2

This is the program that I'm trying to run.

import pyperclip

print(pyperclip.paste())

3 Answers3

0

You might be using a different Python Interpreter in VSCode. "pip install" will add to a global Python Interpreter, but you may not have that one selected in VScode. Try opening the Command Palette (Ctrl+Shift+P) in VScode, start typing the Python: Select Interpreter command, select the command and then check which interpreter VScode is using.

ChriSil
  • 33
  • 1
  • 6
0

Check which python you are using in the IDLE:

enter image description here

And which python you are using in the VSCode:

enter image description here

If they are different, you can click the bottom-left to select the python interpreter:

enter image description here

Or you can install the package again in the environment which you have selected in the VSCode:

Steven-MSFT
  • 7,438
  • 1
  • 5
  • 13
  • They have the same interpreter (Python 3.10.0 64 bit). I also tried reinstalling the package yet no luck. Do you have any other solution? – JoshinglyJosh Nov 23 '21 at 06:28
  • @JoshinglyJosh What's the value of `import sys print(sys.executable)` and `pip show pyperclip`? – Steven-MSFT Nov 23 '21 at 07:34
0

I found this solution to be working.

The problem could be because you are not working from a virtual environment.

  1. Create a virtual environment. with this command. Before that, ls to the folder and run this command in the present working folder.
python3 -m venv "you virtual environment name"
  1. Activate the virtual environment.
source "your virtual environment name>/bin/activate"
  1. Install your modules here. Install pyperclip here.

This should resolve the issue.

S.B
  • 13,077
  • 10
  • 22
  • 49