简体   繁体   English

Python pip安装给出“命令”“ python setup.py egg_info”失败,错误代码为1”

[英]Python pip install gives “Command ”python setup.py egg_info“ failed with error code 1”

Edit: Yes I know this question already exists, except my question is a bit different and none of the solutions fixed it. 编辑:是的,我知道这个问题已经存在,除了我的问题有点不同并且没有解决方案可以解决。

I do most of my Python stuff when I'm at work and not on my personal machine, but I decided to install it on my personal computer as well. 我在工作时(而不是在个人计算机上)执行大部分Python工作,但我决定也将其安装在个人计算机上。 I fresh installed python 3.6.1, and created a virtual environment with virtualenv . 我重新安装了python 3.6.1,并使用virtualenv创建了一个虚拟环境。 Then within the virtualenv I tried to pip install urllib (or any module) and I received the error: 然后在virtualenv中,我尝试点安装urllib(或任何模块),但收到错误消息:

(pdbot) C:\Users\user\Documents\pdbot>pip install urllib
Collecting urllib
  Using cached urllib-1.21.1.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\user\AppData\Local\Temp\pip-build-50tn0wlb\urllib\setup.py", line 191
    s.connect((base64.b64decode(rip), 017620))
                                           ^
    SyntaxError: invalid token

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\user\AppData\Local\Temp\pip-build-50tn0wlb\urllib\

I read elsewhere that this error had something to do with setuptools not being properly installed. 我在其他地方读到此错误与setuptools未正确安装有关。 So I ran this to attempt to fix the issue: 因此,我运行此命令来尝试解决此问题:

easy_install -U setuptools

I ended up receiving an even weirder error next: 我最终收到了一个甚至更奇怪的错误:

(pdbot) C:\Users\zeke\Documents\pdbot>easy_install -U setuptools
Searching for setuptools
Reading https://pypi.python.org/simple/setuptools/
Downloading https://pypi.python.org/packages/a9/23/720c7558ba6ad3e0f5ad01e0d6ea2288b486da32f053c73e259f7c392042/setuptools-36.0.1.zip#md5=430eb106788183eefe9f444a300007f0
Best match: setuptools 36.0.1
Processing setuptools-36.0.1.zip
Writing C:\Users\zeke\AppData\Local\Temp\easy_install-jhg1val_\setuptools-36.0.1\setup.cfg
Running setuptools-36.0.1\setup.py -q bdist_egg --dist-dir C:\Users\zeke\AppData\Local\Temp\easy_install-jhg1val_\setuptools-36.0.1\egg-dist-tmp-8apak7kn
warning: no files found matching '*' under directory 'setuptools\_vendor'
Copying setuptools-36.0.1-py3.6.egg to c:\users\zeke\documents\pdbot\lib\site-packages
Adding setuptools 36.0.1 to easy-install.pth file
Installing easy_install-script.py script to c:\users\zeke\documents\pdbot\Scripts
Installing easy_install.exe script to c:\users\zeke\documents\pdbot\Scripts
error: [WinError 5] Access is denied: 'c:\\users\\zeke\\documents\\pdbot\\Scripts\\easy_install.exe'

This looks like a permissions error, but I ran these both in an administrator command prompt (Windows 10) and got the same result. 这看起来像是权限错误,但我在管理员命令提示符(Windows 10)中都运行了它们,并得到了相同的结果。 I am the only user on this computer and I have all admin permissions. 我是这台计算机上的唯一用户,并且拥有所有管理员权限。 Is this virtualenv causing an issue? 这是virtualenv引起问题吗? How do I remedy it? 我该如何补救?


EDIT: I was able to fix the permissions issue by leveraging the python executable like so: 编辑:我能够通过利用python可执行文件来解决权限问题,如下所示:

python -m easy_install -U setuptools

But it didn't fix the python setup.py egg_info issue. 但是它并没有解决python setup.py egg_info问题。 I still get this error message when trying to pip install anything: 尝试pip install任何内容时,我仍然收到此错误消息:

Command "python setup.py egg_info" failed with error code 1 in C:\Users\user\AppData\Local\Temp\pip-build-50tn0wlb\urllib\

I have tried both python -m pip install urllib and pip install urllib and neither work. 我已经尝试了python -m pip install urllibpip install urllib都没有用。

I had the same problem when trying to install urllib, but after doing a pip search urllib , I discovered that the problem was due to the version of urllib. 尝试安装urllib时遇到相同的问题,但是在进行pip search urllib ,我发现问题是由于urllib的版本引起的。 From the search: 通过搜索:

$ pip search urllib
...
> urllib5 (5.0.0)  - Just increment the number and create a new lib. Never fix the original one.

At the end, a simple 最后,一个简单的

pip install urllib5

within an elevated shell solved it. 在高架壳内解决了它。

There are two points to make in order to answer your question: 为了回答您的问题有两点:

1. You are lucky you did not install that package! 1.幸运的是您没有安装该软件包!

The package you were trying to install was a maliciously created python package that was designed to look like a real package (in this case urllib3 ). 您尝试安装的软件包是一个恶意创建的python软件包,旨在看起来像真实的软件包(在本例中为urllib3 )。 If you had installed it, the package would have operated as normal except it would have sent some basic information about the system on which you installed the package to a URL (you can see more details on this here ). 如果安装了该软件包,则该软件包将正常运行,只是它会将有关安装该软件包的系统的一些基本信息发送到URL(您可以在此处查看更多详细信息)。 You can read more about this fake package at either of the following links: 您可以通过以下任一链接阅读有关此伪造软件包的更多信息:

Sending basic information about your systems to an unknown source isn't the worst thing you could do, but is certainly something you want to avoid when possible. 将有关系统的基本信息发送到未知来源不是您可以做的最坏的事情,但是当然是您希望避免的事情。

2. To properly install a package... 2.要正确安装软件包...

  • Specifically urllib: 特别是urllib:

    To install urllib, you need to specify the version of the package you would like to install. 要安装urllib,您需要指定要安装的软件包的版本。 For example, pip install urllib3 . 例如, pip install urllib3

  • Any package in general: 任何一般包装:

    As @Elisabete Coelho suggested, you can use the pip search <package-name> feature to view the available packages. 正如@Elisabete Coelho所建议的那样,您可以使用pip search <package-name>功能来查看可用的软件包。 This is not perfect, however, as it may list malicious libraries like the one you were trying to install. 但是,这并不完美,因为它可能列出了您尝试安装的恶意库。 A good guideline is that you should follow the installation instructions in a package's documentation closely to avoid any unforeseen issues. 良好的指导原则是,您应严格遵循软件包文档中的安装说明,以避免出现任何不可预见的问题。 This is just an unfortunate necessity of living in a world where people make pretend python packages. 这只是生活在人们伪装python软件包的世界中的不幸必需品。

Your problem has to do with permissions. 您的问题与权限有关。 The related/similar tools setup_tools , easy_install , and pip all tend to set a default set of permissions on files and folders they try to create in the package installation folder(s), rather than trying to match access permissions of the location they're installing in. 相关/相似的工具setup_toolseasy_installpip都倾向于对它们试图在软件包安装文件夹中创建的文件和文件夹设置默认权限集,而不是尝试匹配它们所在位置的访问权限安装在。

On Linux systems, where files and folders individually have permissions, this is frequently bypassed with the sudo command. 在Linux系统上,文件和文件夹分别具有权限,因此经常使用sudo命令绕过它。 On Windows, the equivalent is to run the installer as an Administrator. 在Windows上,等效的操作是以管理员身份运行安装程序。 Since you're in the console, you have to open a console with Administrator privileges to run the pip command in. 由于您在控制台中,因此必须以管理员权限打开控制台才能运行pip命令。

Notable under Windows, the modules installed with pip from an Administrator console are still accessible to all users of the system that have the proper path in the PYTHONPATH system environment variable. 在Windows上值得注意的是,在PYTHONPATH系统环境变量中具有正确路径的系统的所有用户仍可以访问从管理员控制台通过pip安装的模块。 Under Linux however, the problem is exacerbated by the fact that the files themselves may not be created with read and execute access for other users and may need to have their permissions manually modified after installation. 但是,在Linux下,该文件本身可能无法使用其他用户的读取和执行访问权限来创建,并且安装后可能需要手动修改其权限,这一事实使问题更加严重。

WARNING: urllib vs urllib2 vs urllibx 警告:urllib vs urllib2 vs urllibx

Both other answers claim that the problem is you're not specifying the correct "version" of the module in the call to pip . 其他两个答案都认为问题是您没有在对pip的调用中指定模块的正确“版本”。 Neither is correct, as the error clearly indicates an installation folder access permissions violation causing the failure, but they also incorrectly recommended VERY unsafe behavior. 两者都不正确,因为该错误清楚地表明导致失败的安装文件夹访问权限冲突,但是它们也错误地建议非常不安全的行为。

pip install urllib != pip install urllib5 these are two completely different packages. pip install urllib != pip install urllib5这是两个完全不同的软件包。
The documentation for pip ( https://packaging.python.org/tutorials/installing-packages/#id17 ) clearly says the way to specify a module version explicitly is pip install 'urllib==5' . pip的文档( https://packaging.python.org/tutorials/installing-packages/#id17 )明确指出,显式指定模块版本的方法是pip install 'urllib==5'
As part of how the package management engine implemented by pip works, running the command pip install urllib will always try to use the latest version of the urllib package, so you shouldn't need to specify the version unless you have some reason that you need a very specific version of the module. 作为pip实现的软件包管理引擎工作方式的一部分,运行命令pip install urllib将始终尝试使用urllib软件包的最新版本,因此除非您出于某些原因需要,否则无需指定版本。该模块的特定版本。

暂无
暂无

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

相关问题 python pip install poster 给了我错误 --&gt; 命令“python setup.py egg_info”在 C:\\Users\\ 中失败,错误代码为 1 - python pip install poster gives me error --> Command "python setup.py egg_info" failed with error code 1 in C:\Users\ Python pip install jira 1.0.10.tar.gz给出“命令” python setup.py egg_info“失败,错误代码为1” - Python pip install jira 1.0.10.tar.gz gives “Command ”python setup.py egg_info“ failed with error code 1” python3 pip安装在pydns软件包中给出“命令” python setup.py egg_info“失败,错误代码为1” - Python3 pip install gives “Command ”python setup.py egg_info“ failed with error code 1” in pydns package pip install askbot错误-命令“ python setup.py egg_info”失败,错误代码为1 - pip install askbot error - Command “python setup.py egg_info” failed with error code 1 pip install iconsdk:命令“ python setup.py egg_info”失败,错误代码为1 - pip install iconsdk: Command “python setup.py egg_info” failed with error code 1 点安装命令“ python setup.py egg_info”失败,错误代码 - Pip install Command “python setup.py egg_info” failed with error code pip安装日志记录:命令“ python setup.py egg_info”失败,错误代码为1 - pip install logging: Command “python setup.py egg_info” failed with error code 1 返回“命令“ python setup.py egg_info”的Python pip命令失败,错误代码为1” - Python pip command returning 'Command “python setup.py egg_info” failed with error code1' Pip安装形状给出“python setup.py egg_info”失败,错误代码1错误 - Pip install of shapely giving “python setup.py egg_info” failed with error code 1 error 无法使用 Python 3.7 的 pip 安装 pygame - 命令“python setup.py egg_info”失败,错误代码为 1 - Can't install pygame with pip for Python 3.7 - Command "python setup.py egg_info" failed with error code 1
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM