0

Apologies if this has been answered; I am too green to know if someone had my issue. I am going through Automate the Boring Stuff With Python, and am trying to import pyperclip for ch. 6. Below is from the command prompt.

Microsoft Windows [Version 10.0.17134.1246] (c) 2018 Microsoft Corporation. All rights reserved.

C:\Users\anthony.suarez>py -m pip install pyperclip Requirement already satisfied: pyperclip in c:\users\anthony.suarez\appdata\local\programs\python\python39\lib\site-packages (1.8.1)

C:\Users\anthony.suarez>py Python 3.9.1 (tags/v3.9.1:1e5d33e, Dec 7 2020, 17:08:21) [MSC v.1927 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information.

In Mu, importing pyperclip gives me:

Jupyter QtConsole 4.3.1 Python 3.6.3 (v3.6.3:2c5fed8, Oct 3 2017, 18:11:49) [MSC v.1900 64 bit (AMD64)] Type 'copyright', 'credits' or 'license' for more information IPython 6.2.1 -- An enhanced Interactive Python. Type '?' for help.

import pyperclip

ModuleNotFoundError Traceback (most recent call last) in () ----> 1 import pyperclip

ModuleNotFoundError: No module named 'pyperclip'

I see the different versions of Python, but not sure if that is the issue or how to resolve it.

Thanks in advance!

  • Are you sure you installed pyperclip into the correct environment? Which env are you using in Jupyter? – William Baker Morrison Jan 22 '21 at 11:41
  • Ha I am not sure what environment. I started learning Python from multiple sources and had downloaded several IDEs. I ended up deleting everything and reinstalling Python and am sticking with the built in IDLE. Was able to install pyperclip and have no issues now. Thanks for responding. – Asuarez Jan 23 '21 at 15:08

1 Answers1

0

In case you wanted to know what was going on and why you were getting this error:

From your command line prompts:

C:\Users\anthony.suarez>py Python 3.9.1

Meant that your system installation of python when you call it with py is version 3.9.1. When you use py -m pip install <packagename> you are installing your package to this version of python on your system.

An important thing to note is that it is common to have many different versions of Python on one system, all independent of each other. This is because for stability reasons, code is best run on the version of Python it was written/intended for. Languages change as they evolve, and thus legacy code needs legacy interpreters to run correctly.

Jupyter QtConsole 4.3.1 Python 3.6.3 

From Mu means that the Python in Mu is a Jupyter Interpreter running 3.6.3. This is different from the interpreter you installed Pyperclip on.

For better results moving forward, I highly recommend you install the beta version of Mu (this is also recommended in the book you are reading) which has a neat feature for installing packages run in Mu console. Simply click on the cog in the bottom right, click on third party packages, type your package in, and voila everything is installed. This method treats the python interpreter in Mu like it's own environment, which mirrors best practices for coding and that you will see come up when you graduate to more complex IDEs.

Here is a sample GIF of the Mu beta process for installing packages.

https://user-images.githubusercontent.com/37602/51554718-dbd5c800-1e6d-11e9-94d8-03f0b11b7f04.gif

Cambuchi
  • 102
  • 1
  • 9