62

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

C:\>easy_install winpexpect
正在搜索 winpexpect
最佳匹配:winpexpect 1.4
处理winpexpect-1.4-py2.7.egg
winpexpect 1.4 已经是 easy-install.pth 中的活动版本

使用 c:\python27\lib\site-packages\winpexpect-1.4-py2.7.egg
处理 winpexpect 的依赖关系
搜索 pywin32>=214
阅读 http://pypi.python.org/simple/pywin32/
阅读 http://sf.net/projects/pywin32
阅读 http://sourceforge.net/project/showfiles.php?group_id=78018
找不到 pywin32>=214 的本地包或下载链接
最佳匹配:无
回溯(最近一次通话最后):
  文件“C:\python27\scripts\easy_install-script.py”,第 8 行,在
    load_entry_point('setuptools==0.6c11', 'console_scripts', 'easy_install')()
  文件“C:\python27\lib\site-packages\setuptools\command\easy_install.py”,第 1712 行,在 main
    with_ei_usage(lambda:
  文件“C:\python27\lib\site-packages\setuptools\command\easy_install.py”,第 1700 行,在 with_ei_usage
    返回 f()
  文件“C:\python27\lib\site-packages\setuptools\command\easy_install.py”,第 1716 行,在
    distclass=DistributionWithoutHelpCommands, **kw
  文件“C:\python27\lib\distutils\core.py”,第 152 行,在设置中
    dist.run_commands()
  文件“C:\python27\lib\distutils\dist.py”,第 953 行,在 run_commands
    self.run_command(cmd)
  文件“C:\python27\lib\distutils\dist.py”,第 972 行,在 run_command
    cmd_obj.run()
  运行中的文件“C:\python27\lib\site-packages\setuptools\command\easy_install.py”,第 211 行
    self.easy_install(规范,不是 self.no_deps)
  文件“C:\python27\lib\site-packages\setuptools\command\easy_install.py”,第 446 行,在 easy_install
    return self.install_item(spec, dist.location, tmpdir, deps)
  文件“C:\python27\lib\site-packages\setuptools\command\easy_install.py”,第 481 行,在 install_item
    self.process_distribution(spec, dists[0], deps, "使用")
  文件“C:\python27\lib\site-packages\setuptools\command\easy_install.py”,第 519 行,在 process_distribution
    [要求]、self.local_index、self.easy_install
  解析中的文件“C:\python27\lib\site-packages\pkg_resources.py”,第 563 行
    dist = best[req.key] = env.best_match(req, self, installer)
  文件“C:\python27\lib\site-packages\pkg_resources.py”,第 799 行,在 best_match
    return self.obtain(req, installer) # 尝试下载/安装
  文件“C:\python27\lib\site-packages\pkg_resources.py”,第 811 行,在获取
    返回安装程序(要求)
  文件“C:\python27\lib\site-packages\setuptools\command\easy_install.py”,第 434 行,在 easy_install
    self.local_index
  文件“C:\python27\lib\site-packages\setuptools\package_index.py”,第 475 行,在 fetch_distribution
    返回 dist.clone(location=self.download(dist.location, tmpdir))
AttributeError:“NoneType”对象没有属性“克隆”
4

6 回答 6

22

如果您使用的是 Windows 7 64 位版本,则可以在此处找到解决方案:http: //pypi.python.org/pypi/setuptools

也就是说,你需要下载一个python脚本,运行它,然后easy_install就可以从命令行正常工作了。

PS我同意原始海报说这应该开箱即用。

于 2012-12-06T04:52:49.200 回答
9

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

由于它是 Windows 和我们正在谈论的开源,它通常可能是安装方法的混乱组合以使事情正常工作。但是,easy_install 肯定比手动编辑配置文件要好。

于 2010-10-25T16:10:37.807 回答
8

我也同意 OP 的观点,即所有这些东西都应该随 Python 一起提供。我想我们将不得不处理它,直到那一天到来。这是一个实际上对我有用的解决方案:

安装 easy_install 更快更容易

我希望它可以帮助你或任何有同样问题的人!

于 2013-08-01T15:09:04.427 回答
7

从以下 URL 复制以下脚本“ez_setup.py”

https://bootstrap.pypa.io/ez_setup.py

并将其复制到您的 Python 位置

C:\Python27>

运行命令

C:\Python27? python ez_setup.py

这将在 Scripts 目录下安装 easy_install

C:\Python27\脚本

从 Scripts 目录运行轻松安装 >

C:\Python27\Scripts> easy_install

于 2014-11-21T09:02:15.983 回答
1

一方面,它表示您已经安装了该模块。如果你需要升级它,你应该这样做:

easy_install -U 包名

当然,如果包有一些需要编译的 C 头文件并且您没有安装正确版本的 Visual Studio,那么 easy_install 就不能很好地工作。您可以尝试使用 pip 或分发而不是 easy_install,看看它们是否工作得更好。

于 2010-10-25T15:44:25.123 回答
1

如果您使用Anaconda 的Python 发行版,

你可以通过 pip 安装它

pip install setuptools

然后将其作为模块执行

python -m easy_install

于 2017-11-30T06:07:06.000 回答