1

I'm using Windows 10, Python 3.6.4. I'm trying to use the module Pyperclip and have installed it with pip:

c:\Users\Bertie>pip install pyperclip
Requirement already satisfired: pyperclip in c:\python36\lib\site-packages (1.8.0)

But when I try to run a program which uses this module, I get this error:

c:\Users\Bertie\scraping.py test
Traceback (most recent call last):
File "C:\Users\Bertie\scraping.py", line 3, in <module>
    import webbrowser, sys, pyperclip
ModuleNotFoundError: No module named 'pyperclip'

How can I fix this? Thank you.

  • What IDE are you using? – Nathan Jul 16 '20 at 10:03
  • It can have several reasons. Are you have multiple python version on your computer? Did you install the library while having another command line terminal open and then try to execute it in there? Use a new terminal instance instead. There are several more reasons. We need more information. – MisterNox Jul 16 '20 at 10:06
  • Try running the interactive interpreter and see that it actually runs the intended Python, and then see if it can `import pyperclip`. If it can, try starting the program once again but using `python c:\Users\Bertie\scraping.py test` and update the question with your findings. – metatoaster Jul 16 '20 at 10:14
  • @Nathan Pycharm – Bertie Kirkwood Jul 16 '20 at 16:54
  • @metatoaster Thank you! The interactive interpreter has been working with `import pyperclip` line, which was annoying me. Using that command you said in the command line works perfectly though! Why is this? Is it good practice to put `python` always at the start of the line when running a file from the command prompt? – Bertie Kirkwood Jul 16 '20 at 16:58
  • @BertieKirkwood https://stackoverflow.com/questions/62912626/why-do-i-get-the-error-modulenotfounderror-no-module-named-tensorflow-python/62913134#62913134 does my answer here help? – Nathan Jul 16 '20 at 20:09
  • @BertieKirkwood it's not so much a good or bad practice as that's a normal thing that may is possible, however if the environment is misconfigured it may launch a different Python interpreter to the intended one. Though for your specific case I am unsure as to what the cause is. – metatoaster Jul 17 '20 at 00:56

3 Answers3

0

Where is the py file? Maybe try cd-ing into the folder and run python (python3) scraping.py? Also check that you have installed the correct interpreter and are using the correct version of python.

0

The reinstall trace shows you install the packge successflly for python36. Check if there is more than one python in your system. Type "python" in your windows cmd console, and check the python version to see if python36 is the default one. Then explicitly use the python interpreter to start the script "python your_python_script.py".

0

Maybe You Installed pyperclip in conda env or a virtualenv and you forgot to activate it ?

Because This Has Happened To Me Many Times.

Or Maybe You Have 2 Instances Of Python installed on your computer and you accidentally installed pyperclip in the other instance of python ?

Aryan
  • 1,093
  • 9
  • 22