Reputation: 25
I've been trying to learn python using Automate the Boring Stuff with Python (has not been as easy as I would have liked). In chapter 6, the author is using a module he created for a project. I seemingly installed the module successfully, but I'm getting the following error when I run his sample code:
import pyperclip
pyperclip.copy('Hello, world!')
pyperclip.paste()
Traceback (most recent call last):
File "C:\Users\16463\OneDrive\Desktop\test.py", line 1, in <module>
import pyperclip
ModuleNotFoundError: No module named 'pyperclip'
I'm using Thonny IDE.
Upvotes: 2
Views: 520
Reputation: 7012
Thonny uses its own Python interpreter by default. Unless you have changed the interpreter (Run => Select interpreter), Thonny's Python doesn't use c:\users\16463\python\python37-32\lib\site-packages
You should either install pyperclip to Thonny's bundled Python ("Tools => Manage packages" or "Tools => Open system shell") or make Thonny use your other Python ("Run => Select interpreter")
Upvotes: 0
Reputation: 4131
Look at Update #1 below for the answer.
You need to install the pyperclip
module before using it.
In your terminal, execute the following command to install pyperclip
.
pip install pyperclip
Reference:
UPDATE #1
I see that in one of your comments you said that you are using Thonny IDE.
You can install packages in Thonny IDE from Tools -> Manage Packages. There you can search for required packages and install them.
Upvotes: 1
Reputation: 1064
First, make sure you only use a single version of Python, preferably the latest. It's possible that you have multiple versions installed and are using one for which the module was not installed.
I seemingly installed the module successfully
To test this, let's get the list of third-party packages you have installed. open a command line and run pip freeze -l
. Make sure pyperclip is indeed on the list.
If it isn't on the list, try installing again (with pip install pyperclip
).
If it is on the list and yet you are getting ModuleNotFoundError
, make sure pyperclip is spelled correctly. It could be the case that you had a typo during installation with pip, and installed, say, pyperclkp instead.
Upvotes: 0
Reputation: 31
The error: No module named 'pyperclip', means the module is not installed correctly.
You can find more details of how to install third party module in Appendix A of the book.
I installed pyperclip successfully by typing "pip install --user pyperclip" in cmd, you can give it a try.
Upvotes: 0