Wednesday, February 16, 2022

[SOLVED] Can't import pyperclip after installation of pip3 in Debian Linux

Issue

I've installed pip in Debian Linux (I'm using an ARM Chromebook with the Linux beta)

sudo apt-get install python3-pip

which returns:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
python3-pip is already the newest version (18.1-5).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

However in IDLE if I try to import pyperclip, I get:

>>> import pyperclip

Traceback (most recent call last):

  File "<pyshell#23>", line 1, in <module>

    import pyperclip

ModuleNotFoundError: No module named 'pyperclip'

Any idea what's going wrong here or how I can investigate?

If I run sys.path in my IDLE Python Shell and in the command line I seem to get the same results:

IDLE: ['', '/home/test', '/usr/bin', '/usr/lib/python37.zip', '/usr/lib/python3.7', '/usr/lib/python3.7/lib-dynload', '/usr/local/lib/python3.7/dist-packages', '/usr/lib/python3/dist-packages']

Command Line: test@penguin:~$ python3 Python 3.7.3 (default, Dec 20 2019, 18:57:59) [GCC 8.3.0] on linux Type "help", "copyright", "credits" or "license" for more information.

import sys sys.path ['', '/usr/lib/python37.zip', '/usr/lib/python3.7', '/usr/lib/python3.7/lib-dynload', '/usr/local/lib/python3.7/dist-packages', '/usr/lib/python3/dist-packages']


Solution

Well you have to install pyperclip before you can use it, because it is not part of the python3-pip package. pip is an installer which allows you to install python packages like pyperclip.

sudo pip3 install pyperclip

After the successful installation you can use it with python:

In [1]: import pyperclip

In [2]: pyperclip.__path__
Out[2]: ['/usr/local/lib/python3.7/dist-packages/pyperclip']



Answered By - cronoik
Answer Checked By - Pedro (WPSolving Volunteer)