如何使用 Python 的“easy_install"在 Windows 上……这并不容易 [英] How to use Python's "easy_install" on Windows ... it's not so easy

查看:31
本文介绍了如何使用 Python 的“easy_install"在 Windows 上……这并不容易的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Windows XP 上安装 Python 2.7 后,然后手动将 %PATH% 设置为 python.exe(为什么 python 安装程序不这样做?),然后安装setuptools 0.6c11(为什么python安装程序不这样做?),然后手动将%PATH%设置为easy_install.exe(为什么安装程序不这样做?),我终于尝试使用 easy_install 安装 python 包,但是 easy_install 无法安装 pywin32 包时失败了,这是是一种依赖.如何使easy_install 在Windows XP 上正常运行?失败如下:

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_install failed 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:

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'

推荐答案

一个问题是 easy_install 设置为下载和安装 .egg 文件或源分发(包含在 .tgz、.tar、.tar.gz、.tar.bz2 或 .zip 文件).它不知道如何处理 PyWin32 扩展,因为它们被放在单独的安装程序可执行文件中.您需要下载适当的 PyWin32 安装程序文件(适用于 Python 2.7)并自行运行.当您再次运行 easy_install 时(前提是您已正确安装,就像 Sergio 的说明中所述),您应该会看到您的 winpexpect 包已正确安装.

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.

因为我们谈论的是 Windows 和开源,所以它通常可能是安装方法的混乱组合,以使事情正常工作.不过,easy_install 肯定还是比手工编辑配置文件要好.

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.

这篇关于如何使用 Python 的“easy_install"在 Windows 上……这并不容易的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆