如何在 Windows 上使用 Python 的“easy_install”……没那么容易
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4016151/
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
How to use Python's "easy_install" on Windows ... it's not so easy
提问by Nick
After installing Python 2.7 on Windows XP, then manually setting the %PATH%to python.exe(why won't the python installer do this?), then installing setuptools 0.6c11(why doesn't the python installer do this?), then manually setting the %PATH%to easy_install.exe(why doesn't the installer do this?), I finally tried to install a python package with easy_install, but easy_installfailed when it couldn't install the pywin32 package, which is a dependency. How can I make easy_install work properly on Windows XP?The failure follows:
在 Windows XP 上安装 Python 2.7 后,然后手动设置%PATH%to python.exe(为什么 python 安装程序不这样做?),然后安装setuptools 0.6c11(为什么 python 安装程序不这样做?),然后手动设置%PATH%to easy_install.exe(为什么不这样做?)安装程序是否执行此操作?),我终于尝试使用 安装一个 python 包easy_install,但是easy_install当它无法安装 pywin32 包时失败了,这是一个依赖项。如何使 easy_install 在 Windows XP 上正常工作?故障如下:
C:\>easy_install winpexpect
Searching for winpexpect
Best match: winpexpect 1.4
Processing winpexpect-1.4-py2.7.egg
winpexpect 1.4 is already the active version in easy-install.pth
Using c:\python27\lib\site-packages\winpexpect-1.4-py2.7.egg
Processing dependencies for winpexpect
Searching for pywin32>=214
Reading http://pypi.python.org/simple/pywin32/
Reading http://sf.net/projects/pywin32
Reading http://sourceforge.net/project/showfiles.php?group_id=78018
No local packages or download links found for pywin32>=214
Best match: None
Traceback (most recent call last):
File "C:\python27\scripts\easy_install-script.py", line 8, in
load_entry_point('setuptools==0.6c11', 'console_scripts', 'easy_install')()
File "C:\python27\lib\site-packages\setuptools\command\easy_install.py", line 1712, in main
with_ei_usage(lambda:
File "C:\python27\lib\site-packages\setuptools\command\easy_install.py", line 1700, in with_ei_usage
return f()
File "C:\python27\lib\site-packages\setuptools\command\easy_install.py", line 1716, in
distclass=DistributionWithoutHelpCommands, **kw
File "C:\python27\lib\distutils\core.py", line 152, in setup
dist.run_commands()
File "C:\python27\lib\distutils\dist.py", line 953, in run_commands
self.run_command(cmd)
File "C:\python27\lib\distutils\dist.py", line 972, in run_command
cmd_obj.run()
File "C:\python27\lib\site-packages\setuptools\command\easy_install.py", line 211, in run
self.easy_install(spec, not self.no_deps)
File "C:\python27\lib\site-packages\setuptools\command\easy_install.py", line 446, in easy_install
return self.install_item(spec, dist.location, tmpdir, deps)
File "C:\python27\lib\site-packages\setuptools\command\easy_install.py", line 481, in install_item
self.process_distribution(spec, dists[0], deps, "Using")
File "C:\python27\lib\site-packages\setuptools\command\easy_install.py", line 519, in process_distribution
[requirement], self.local_index, self.easy_install
File "C:\python27\lib\site-packages\pkg_resources.py", line 563, in resolve
dist = best[req.key] = env.best_match(req, self, installer)
File "C:\python27\lib\site-packages\pkg_resources.py", line 799, in best_match
return self.obtain(req, installer) # try and download/install
File "C:\python27\lib\site-packages\pkg_resources.py", line 811, in obtain
return installer(requirement)
File "C:\python27\lib\site-packages\setuptools\command\easy_install.py", line 434, in easy_install
self.local_index
File "C:\python27\lib\site-packages\setuptools\package_index.py", line 475, in fetch_distribution
return dist.clone(location=self.download(dist.location, tmpdir))
AttributeError: 'NoneType' object has no attribute 'clone'
采纳答案by Brandon
One problem is that easy_install is set up to download and install .egg files or source distributions (contained within .tgz, .tar, .tar.gz, .tar.bz2, or .zip files). It doesn't know how to deal with the PyWin32 extensions because they are put within a separate installer executable. You will need to download the appropriate PyWin32 installer file (for Python 2.7) and run it yourself. When you run easy_install again (provided you have it installed right, like in Sergio's instructions), you should see that your winpexpect package has been installed correctly.
一个问题是 easy_install 设置为下载和安装 .egg 文件或源分发(包含在 .tgz、.tar、.tar.gz、.tar.bz2 或 .zip 文件中)。它不知道如何处理 PyWin32 扩展,因为它们被放在一个单独的安装程序可执行文件中。您需要下载适当的 PyWin32 安装程序文件(适用于 Python 2.7)并自行运行。当您再次运行 easy_install 时(假设您已正确安装它,就像在 Sergio 的说明中一样),您应该看到您的 winpexpect 包已正确安装。
Since it's Windows and open source we are talking about, it can often be a messy combination of install methods to get things working properly. However, easy_install is still better than hand-editing configuration files, for sure.
由于我们谈论的是 Windows 和开源,它通常可能是安装方法的混乱组合,以使事情正常工作。然而,easy_install 仍然比手工编辑配置文件要好,这是肯定的。
回答by Mike Driscoll
For one thing, it says you already have that module installed. If you need to upgrade it, you should do something like this:
一方面,它表示您已经安装了该模块。如果你需要升级它,你应该做这样的事情:
easy_install -U packageName
easy_install -U 包名
Of course, easy_install doesn't work very well if the package has some C headers that need to be compiled and you don't have the right version of Visual Studio installed. You might try using pip or distribute instead of easy_install and see if they work better.
当然,如果包有一些需要编译的 C 头文件并且你没有安装正确版本的 Visual Studio,easy_install 就不会很好地工作。您可以尝试使用 pip 或分发而不是 easy_install 并查看它们是否工作得更好。
回答by Gabriel
If you are using windows 7 64-bit version, then the solution is found here: http://pypi.python.org/pypi/setuptools
如果您使用的是 Windows 7 64 位版本,则可以在此处找到解决方案:http: //pypi.python.org/pypi/setuptools
namely, you need to download a python script, run it, and then easy_install will work normally from commandline.
也就是说,你需要下载一个python脚本,运行它,然后easy_install就可以从命令行正常工作了。
P.S. I agree with the original poster saying that this should work out of the box.
PS 我同意原始海报说这应该是开箱即用的。
回答by Eenvincible
I also agree with the OP that all these things should come with Python already set. I guess we will have to deal with it until that day comes. Here is a solution that actually worked for me :
我也同意 OP 所有这些东西都应该随 Python 一起设置。我想我们将不得不处理它,直到那一天到来。这是一个实际上对我有用的解决方案:
installing easy_install faster and easier
I hope it helps you or anyone with the same problem!
我希望它可以帮助您或任何有同样问题的人!
回答by kadi99
Copy the below script "ez_setup.py" from the below URL
从以下 URL 复制以下脚本“ez_setup.py”
https://bootstrap.pypa.io/ez_setup.py
https://bootstrap.pypa.io/ez_setup.py
And copy it into your Python location
并将其复制到您的 Python 位置
C:\Python27>
C:\Python27>
Run the command
运行命令
C:\Python27? python ez_setup.py
C:\Python27? 蟒蛇ez_setup.py
This will install the easy_install under Scripts directory
这将在 Scripts 目录下安装 easy_install
C:\Python27\Scripts
C:\Python27\Scripts
Run easy install from the Scripts directory >
从 Scripts 目录运行简易安装 >
C:\Python27\Scripts> easy_install
C:\Python27\Scripts> easy_install
回答by Danilo Gasques
If you are using Anaconda'sPython distribution,
如果您使用的是Anaconda 的Python 发行版,
you can install it through pip
你可以通过pip安装
pip install setuptools
pip install setuptools
and then execute it as a module
然后将其作为模块执行
python -m easy_install
python -m easy_install

