4

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.

Manos Nikolaidis
  • 18,967
  • 11
  • 60
  • 72
Max
  • 111
  • 1
  • 2
  • 7

9 Answers9

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!

  • So i open up CMD on my desktop and typed in pip install pyperclip, but it show me an invalid syntax error. – Max Nov 11 '15 at 00:49
  • 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. – Alexander Køpke Jul 25 '16 at 21:32
4

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

Einsteinium
  • 66
  • 13
viraptor
  • 30,857
  • 7
  • 96
  • 176
  • I ran it from my CMD as described in my question. Please advise. – Max Nov 11 '15 at 00:49
  • 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:/.....>` – viraptor Nov 11 '15 at 06:42
  • 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.' – Max Nov 12 '15 at 08:09
  • That means you either don't have pip in your path, or it's not installed at all. Please check this question http://stackoverflow.com/questions/4750806/how-to-install-pip-on-windows or the official documentation https://pip.pypa.io/en/latest/installing/ – viraptor Nov 12 '15 at 08:50
3

sudo pip3 install pyperclip

did the trick for me

droschky
  • 31
  • 2
  • 1
    This is the same issue I had. I wrote a blog on this with my detail investigation: Python and Packages: https://davidchuprogramming.blogspot.com/2018/09/python-and-packages.html – David.Chu.ca Sep 26 '18 at 16:28
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

Keyur Potdar
  • 6,669
  • 6
  • 23
  • 36
Exekute
  • 33
  • 5
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)

Enrique Benito Casado
  • 1,480
  • 1
  • 10
  • 18
0

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

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.

Nathan Tuggy
  • 2,239
  • 27
  • 28
  • 36
0

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

Brandon Barney
  • 2,255
  • 1
  • 6
  • 18
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()