简体   繁体   English

ModuleNotFoundError:没有名为“pyperclip”的模块

[英]ModuleNotFoundError: No module named 'pyperclip'

Similar issues like this have been posted on StackOverflow but I did not find adequate answers to resolve this issue.像这样的类似问题已发布在 StackOverflow 上,但我没有找到足够的答案来解决此问题。

I'm running Python 3.6.3 on a Windows 7 machine.我在 Windows 7 机器上运行 Python 3.6.3。 From IDLE I type the following import stmt and get the subsequent error:在 IDLE 中,我输入以下 import stmt 并得到后续错误:

>>> import pyperclip
Traceback (most recent call last):
  File "<pyshell#5>", line 1, in <module>
    import pyperclip
ModuleNotFoundError: No module named 'pyperclip'

I tried hitting Win-R (to pup up the RUN window) and typed the following:我尝试按 Win-R(弹出运行窗口)并输入以下内容:

pip3 install pyperclip
pip install pyperclip

But it gives me an error saying "Could not fetch the URL: https://pypi.python.org/simple/pyperclip/ Could not find a version that satisfies the requirement pyperclip... No Matching distribution found"但它给了我一个错误,说“无法获取 URL: https://pypi.python.org/simple/pyperclip/找不到满足 pyperclip 要求的版本......找不到匹配的分布”

If I visit the URL mentioned ( https://pypi.python.org/simple/pyperclip/ ) I see a bunch of pyperclip ZIP files all dif versions.如果我访问提到的 URL ( https://pypi.python.org/simple/pyperclip/ ),我会看到一堆 pyperclip ZIP 文件所有 dif 版本。 But if I select a version I'm not sure where to place them/extract them or if extracting them is even the right thing to do.但是,如果我 select 一个版本,我不确定将它们放在哪里/提取它们,或者提取它们是否是正确的事情。

Any advice?有什么建议吗?

You must navigate to your default install location for 3.6.您必须导航到 3.6 的默认安装位置。 For IDLE 32 bits it's:对于空闲 32 位,它是:

C:\Users\<username>\AppData\Local\Programs\Python\Python36-32\Scripts\

for IDLE 64 bits use:对于空闲 64 位使用:

C:\Users\<username>\AppData\Local\Programs\Python\Python36\Scripts\

If you navigate to that directory in the command prompt (use cd command), then the command如果您在命令提示符下导航到该目录(使用 cd 命令),则命令

pip install pyperclip

should work.应该管用。

There is a problem with the current version of the pyperclip I checked the git repo and opened a pull request for the issue.当前版本的 pyperclip 存在问题,我检查了 git repo 并针对该问题打开了拉取请求。 It currently doesn't support use for python3.7目前不支持使用 python3.7

Open cmd and type pip install pyperclip with no double quote.打开 cmd 并键入pip install pyperclip带双引号的 pyperclip。

Enter to run for installation.输入运行安装。

If you install successfully, you can import in IDLE.如果安装成功,可以在 IDLE 中导入。

For manual Installation,对于手动安装,

I went to the link you provided in your question.我去了你在问题中提供的链接

Since all of them are pyperclip 1.5 , I wouldn't mind downloading any one of them.由于所有这些都是pyperclip 1.5 ,我不介意下载其中任何一个。

However, the person who designed the site must want you to click on the topmost link , instead of scrolling all the way down.但是,设计该站点的人必须希望您单击最上面的链接,而不是一直向下滚动。

So I downloaded the 1.5.11 version, which was on the top.所以我下载了1.5.11版本,在上面。

And on downloading (I am using my phone) I quickly extracted the zip and saw a nice setup.py file there.在下载(我正在使用我的手机)时,我快速解压缩了 zip,并在那里看到了一个不错的 setup.py 文件。

Btw, I wouldn't worry where to unzip or run the setup.py file.顺便说一句,我不会担心在哪里解压缩或运行 setup.py 文件。

pyperclip 解压

Go ahead and run the setup.py and let it take its time.继续运行setup.py让它setup.py来。

Once done, still not working in IDLE?完成后,仍然无法在 IDLE 中工作? I suggest use CMD(windows) or Terminal(Linux) and check if it is working there, and then come back to me.我建议使用 CMD(windows) 或 Terminal(Linux) 并检查它是否在那里工作,然后再回来找我。

Edit : On having problems installing the setup.py , open CMD as administrator by right clicking and selecting it from the start menu.编辑:在安装setup.py遇到问题,通过右键单击并从开始菜单中选择它来以管理员身份打开 CMD。

Navigate to the directory where setup.py is located and run it inside the CMD, by typing 'setup.py' and press Enter.导航到setup.py所在的目录并在 CMD 中运行它,输入“setup.py”并按 Enter。

Thanks, it worked for me too.谢谢,它也对我有用。 See below details as written above:请参阅上面写的以下详细信息:

Thanks Sayan!谢谢萨扬! It works now.它现在有效。 Just to clarify and detail what I did (if it helps others):只是为了澄清和详细说明我所做的(如果它对其他人有帮助):

  1. downloaded the zip file and extracted the folder contents to a location on C drive下载 zip 文件并将文件夹内容解压缩到 C 驱动器上的某个位置
  2. Click the "Start" button and type "cmd."单击“开始”按钮并键入“cmd”。 Right-click "Cmd," select "Run as Administrator" 3)右键单击“Cmd”,选择“以管理员身份运行” 3)
  3. changed directory to where the setup.py file is located in the folder I just extracted将目录更改为 setup.py 文件在我刚刚提取的文件夹中所在的位置
  4. typed "setup.py install"输入“setup.py install”
  5. Now I'm able to import the module into my code现在我可以将模块导入到我的代码中

Go to windows and search for your IDE (eg VsCode) Go 到 windows 并搜索您的 IDE(例如 VsCode)

在此处输入图像描述

Then Go to the folder of your IDE and go to the properties of file that end .exe go to properties -> compatibility -> [✔️] Run this program as an administrator (apply and then Ok) Then Go to the folder of your IDE and go to the properties of file that end .exe go to properties -> compatibility -> [✔️] Run this program as an administrator (apply and then Ok)

在此处输入图像描述 在此处输入图像描述

i had this problem too: and i solved running: python -m pip install pyperclip我也有这个问题:我解决了运行: python -m pip install pyperclip

note: replace for python that is being used, for example, if you are trying running in python 3.10: python3.10 -m pip install pyperclip注意:替换正在使用的 python,例如,如果您尝试在 python 3.10 中运行: python3.10 -m pip install pyperclip

this problem may is because you may more than one python environment which one of then have no pyperclip installed这个问题可能是因为您可能有多个 python 环境,其中一个没有安装 pyperclip

Manual installation of pyperclip is possible.可以手动安装pyperclip Just download the version you want from https://pypi.org/simple/pyperclip/ , extract it and run setup.py install (or python setup.py install ) in the extracted folder.只需从https://pypi.org/simple/pyperclip/下载你想要的版本,解压并在解压文件夹中运行setup.py install (或python setup.py install )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM