Max
Max

Reputation: 141

Python 3.5 Pyperclip module import failure

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.

Upvotes: 5

Views: 42617

Answers (10)

anusha.V
anusha.V

Reputation: 81

//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

Upvotes: 0

viraptor
viraptor

Reputation: 34155

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

Upvotes: 4

Stephen Samonte Tan
Stephen Samonte Tan

Reputation: 342

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()

Upvotes: 0

Enrique Benito Casado
Enrique Benito Casado

Reputation: 2080

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

Upvotes: 1

droschky
droschky

Reputation: 41

sudo pip3 install pyperclip

did the trick for me

Upvotes: 4

Exekute
Exekute

Reputation: 33

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

Upvotes: 2

CodeMedic
CodeMedic

Reputation: 21

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

Upvotes: 1

Terimis
Terimis

Reputation: 1

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.

Upvotes: 0

Mantahan Srivastava
Mantahan Srivastava

Reputation: 11

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

Upvotes: 0

Alexander Køpke
Alexander Køpke

Reputation: 94

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!

Upvotes: 6

Related Questions