Python 3.5 Pyperclip module import failure
Asked Answered
L

10

5

Just started learning Python. And i'm having trouble using the Pyperclip module.

When I tried to use the pip install pyperclip in the command line, it shows up this error:

pip install pyperclip
          ^
SyntaxError: invalid syntax

I am running Python 3.5 (32 bit) on a Windows 7 desktop.

Leesa answered 2/11, 2015 at 0:42 Comment(0)
J
6

open command prompt type: pip install pyperclip

if this doesn't work then do this use cd Python35/Scripts to get to the scripts folder This is the folder where pip is located.

Now type: pip install pyperclip

This will download and install pyperclip

now type: pip freeze

And pyperclip should be listed

If you want to test in python shell remember to close the shell(if open) and open new one because it needs to load the new package.

type in python shell: import pyperclip

it should accept it and now you can pyperclip.copy() and pyperclip.paste()

Good luck!

Justen answered 2/11, 2015 at 15:39 Comment(2)
So i open up CMD on my desktop and typed in pip install pyperclip, but it show me an invalid syntax error.Leesa
yes and then find the scripts folder in the python folder. It is found somewhere like C:\Users\yourUserName\AppData\Local\Programs\Python and here you can see your python version folder. cd to that folder and finally you can see the scripts folder where pip is. It is a bit of work getting there. Do a dir to make sure the pip files are there. If they are now you can write: pip install pyperclip. It should now install the pyperclip module and you can start using it right away.Faxon
P
4

pip install ... is not python code. You have to run it from the terminal/command prompt.

Pinnatisect answered 2/11, 2015 at 0:54 Comment(4)
I ran it from my CMD as described in my question. Please advise.Leesa
If you get syntax errors, then you didn't. You ran it inside of python shell. Pay attention to the prompt. Python shell will have >>>, or similar. win/dos shell will have C:/.....>Pinnatisect
Ok, so I ran ' pip install pyperclip' in my laptop's CMD. But it returned this : ' pip is not recognized as internal or external command, operable program or batch files.'Leesa
That means you either don't have pip in your path, or it's not installed at all. Please check this question #4751306 or the official documentation pip.pypa.io/en/latest/installingPinnatisect
K
4

sudo pip3 install pyperclip

did the trick for me

Kinsman answered 15/6, 2018 at 5:6 Comment(1)
This is the same issue I had. I wrote a blog on this with my detail investigation: Python and Packages: davidchuprogramming.blogspot.com/2018/09/…Hohenlohe
K
2

This method is better:

  1. Download the zip file of the pyperclip from https://pypi.python.org/packages/8b/4b/8ab1608291f863c501b02af3a607ae43e8e7134a266804b4c8c452feb84f/pyperclip-1.5.7.zip#md5=678e42420aa569b15e82636dc73ed7c5
  2. Extract the file and copy to

    C:\Users\YourUserName\AppData\Local\Programs\Python\Python36-32\lib

  3. Copy the pyperclip the python file into the lib folder
  4. Try the import pyperclip on the python shell again.

I guess you are good to go

Kamchatka answered 26/1, 2018 at 10:25 Comment(0)
B
1

For me, this installed pip at C:\Users\YourUserName\AppData\Local\Programs\Python\Python36-32\Scripts\pip.exe.

Find pip.exe on your computer, then add its folder (for example, C:\Users\YourUserName\AppData\Local\Programs\Python\Python36-32\Scripts) to your path (Start / Edit environment variables).

Now you should be able to run pip from the command line. Try installing a package;

Open default commandline and type: pip install pyperclip

Blayze answered 24/10, 2017 at 18:39 Comment(0)
B
1

Could be that you are using "Jupyter notebook" ? . Jupyter doesn't support all the modules in python like (tkinter , pyperlip .. and much more others)

Binomial answered 29/10, 2018 at 19:17 Comment(0)
B
0

Don't Write it inside python.exe Just open the command prompt and write pip install pyperclip

Bybee answered 27/6, 2017 at 12:3 Comment(1)
Asked and answerd. More complete and properly formatted.Fernandes
K
0
sudo apt-get install python3-pip  
sudo pip3 install --upgrade pip
sudo pip3 install setuptools
sudo pip3 install pyperclip

This is what I had to do to get pyperclip to work on a Linux Mint box.

Kreis answered 2/7, 2017 at 2:40 Comment(0)
M
0

It sounds like you're trying to run a python script. add the pyperclip package to python using:

$ pip install pyperclip

If you run the command again you should get this message. If not then address the error by installing the additional packages it asks for. enter image description here

In the script you want to run, make sure you import the package to be able to access. In your file you should have:

import pyperclip

# What ever commands you want to run
pyperclip.copy('Hello, world!')
pyperclip.paste()
Mercaptide answered 16/5, 2020 at 6:41 Comment(0)
A
0

//These below three commands worked for MacBook Pro to install Pip & Pyperclip

1./Library/Frameworks/Python.framework/Versions/3.9/bin/python3.9 -m pip install --upgrade pip 2./Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/scripts 3.sudo pip3 install pyperclip

output: Downloading pip-21.2.4-py3-none-any.whl (1.6 MB) |████████████████████████████████| 1.6 MB 3.7 MB/s Installing collected packages: pip Attempting uninstall: pip Found existing installation: pip 21.2.3 Uninstalling pip-21.2.3: Successfully uninstalled pip-21.2.3 Successfully installed pip-21.2.4

Collecting pyperclip Downloading pyperclip-1.8.2.tar.gz (20 kB) Using legacy 'setup.py install' for pyperclip, since package 'wheel' is not installed. Installing collected packages: pyperclip Running setup.py install for pyperclip ... done Successfully installed pyperclip-1.8.2

Abruzzi answered 27/9, 2021 at 21:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.