Python 3.5 Pyperclip 模块导入失败

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/33469015/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 13:24:44  来源:igfitidea点击:

Python 3.5 Pyperclip module import failure

pythonpython-3.xpyperclip

提问by Max

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

刚开始学Python。我在使用 Pyperclip 模块时遇到了问题。

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

当我尝试pip install pyperclip在命令行中使用时,它显示了这个错误:

pip install pyperclip
          ^
SyntaxError: invalid syntax

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

我在 Windows 7 桌面上运行 Python 3.5(32 位)。

回答by viraptor

pip install ...is not python code. You have to run it from some shell/commandline.

pip install ...不是python代码。您必须从某个 shell/命令行运行它。

回答by Alexander K?pke

open command prompt type: pip install pyperclip

打开命令提示符类型: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.

如果这不起作用,那么使用 cd Python35/Scripts 进入脚本文件夹这是 pip 所在的文件夹。

Now type: pip install pyperclip

现在输入:pip install pyperclip

This will download and install pyperclip

这将下载并安装 pyperclip

now type: pip freeze

现在输入:pip冻结

And pyperclip should be listed

应该列出 pyperclip

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.

如果你想在 python shell 中测试,记得关闭 shell(如果打开)并打开一个新的,因为它需要加载新包。

type in python shell: import pyperclip

在 python shell 中输入:import pyperclip

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

它应该接受它,现在你可以 pyperclip.copy() 和 pyperclip.paste()

Good luck!

祝你好运!

回答by Mantahan Srivastava

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

不要在python.exe里面写 直接打开命令提示符写 pip install pyperclip

回答by Terimis

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.

这是我必须做的才能让 pyperclip 在 Linux Mint 盒子上工作。

回答by CodeMedic

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

对我来说,这安装pipC:\Users\YourUserName\AppData\Local\Programs\Python\Python36-32\Scripts\pip.exe.

Find pip.exeon 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).

pip.exe在您的计算机上查找,然后将其文件夹(例如C:\Users\YourUserName\AppData\Local\Programs\Python\Python36-32\Scripts)添加到您的路径(启动/编辑环境变量)。

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

现在您应该可以从命令行运行pip了。尝试安装一个包;

Open default commandline and type: pip install pyperclip

打开默认命令行并输入: pip install pyperclip

回答by Exekute

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.
  1. https://pypi.python.org/packages/8b/4b/8ab1608291f863c501b02af3a607ae43e8e7134a266804b4c8c452feb84f/pyperclip-1.zip#253725375clip-1.5256edclip-1.57375c85c56edclip-1.56e5clip-1.5.5000001b02af3a607ae43e8e7134a266804下载pyperclip的zip文件
  2. 提取文件并复制到

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

  3. 将pyperclip的python文件复制到lib文件夹中
  4. 再次尝试在 python shell 上导入 pyperclip。

I guess you are good to go

我想你很高兴去

回答by droschky

sudo pip3 install pyperclip

须藤 pip3 安装 pyperclip

did the trick for me

对我有用

回答by Enrique Benito Casado

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

可能是您正在使用“Jupyter notebook”吗?. Jupyter 不支持 python 中的所有模块,如(tkinter、pyperlip .. 等等)

回答by Stephen Samonte Tan

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

听起来您正在尝试运行 python 脚本。pyperclip使用以下命令将包添加到 python:

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