首页 文章

如何使用Python 's “easy_install” on Windows … it'不是那么容易

提问于
浏览
61

在Windows XP上安装Python 2.7之后,然后手动将 %PATH% 设置为 python.exe (为什么python安装程序不会这样做?),然后安装 setuptools 0.6c11 (为什么python安装程序不执行此操作?),然后手动将 %PATH% 设置为 easy_install.exe (安装程序为什么不这样做?),我终于尝试用 easy_install 安装一个python包,但是当它无法安装pywin32软件包时, easy_install 失败了,这是一个依赖项 . How can I make easy_install work properly on 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'

6 回答

  • 0

    一个问题是easy_install被设置为下载和安装.egg文件或源发行版(包含在.tgz,.tar,.tar.gz,.tar.bz2或.zip文件中) . 它不知道如何处理PyWin32扩展,因为它们被放置within a separate installer executable . 您需要下载相应的PyWin32安装程序文件(适用于Python 2.7)并自行运行 . 当您再次运行easy_install时(如果您已正确安装它,就像在Sergio的说明中那样),您应该看到您的winpexpect软件包已正确安装 .

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

  • 6

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

    即,你需要下载一个python脚本,运行它,然后easy_install将从命令行正常工作 .

    附:我同意原始的海报说这应该开箱即用 .

  • 23

    我也同意OP,所有这些东西都应该在Python中设置 . 我想我们将不得不处理它直到那一天到来 . 这是一个实际上对我有用的解决方案:

    installing easy_install faster and easier

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

  • 9

    从以下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

    从Scripts目录>运行轻松安装

    C:\ Python27 \ Scripts> easy_install

  • 9

    首先,它说你已经安装了该模块 . 如果你需要升级它,你应该这样做:

    easy_install -U packageName

    当然,如果包中有一些需要编译的C头并且没有安装正确版本的Visual Studio,easy_install也不能很好地工作 . 您可以尝试使用pip或distribute而不是easy_install,看看它们是否更好用 .

  • 1

    如果您正在使用Anaconda's Python发行版,

    你可以通过pip安装它

    pip install setuptools

    然后将其作为模块执行

    python -m easy_install

相关问题