【问题标题】:Error in installing setuptools (unorderable types: str() < NoneType())安装 setuptools 时出错(不可排序的类型:str() < NoneType())
【发布时间】:2015-01-12 03:19:36
【问题描述】:

Python 3.4.2,32 位 - Win 8.1,64 位

首先我尝试升级 setuptools,但没有成功。所以我决定卸载以前的版本。现在我无法安装 setuptools。我尝试了以下方法:

  1. pip install setuptools:

    Exception:
    Traceback (most recent call last):
      File "C:\Python34\lib\site-packages\pip\basecommand.py", line 232, in main
        status = self.run(options, args)
      File "C:\Python34\lib\site-packages\pip\commands\install.py", line 339, in run
    
        requirement_set.prepare_files(finder)
      File "C:\Python34\lib\site-packages\pip\req\req_set.py", line 229, in prepare_
    files
        req_to_install.check_if_exists()
      File "C:\Python34\lib\site-packages\pip\req\req_install.py", line 928, in chec
    k_if_exists
        self.satisfied_by = pkg_resources.get_distribution(self.req)
      File "C:\Python34\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", li
    ne 461, in get_distribution
        dist = get_provider(dist)
      File "C:\Python34\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", li
    ne 341, in get_provider
        return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]
      File "C:\Python34\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", li
    ne 870, in require
        needed = self.resolve(parse_requirements(requirements))
      File "C:\Python34\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", li
    ne 740, in resolve
        env = Environment(self.entries)
      File "C:\Python34\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", li
    ne 927, in __init__
        self.scan(search_path)
      File "C:\Python34\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", li
    ne 957, in scan
        self.add(dist)
      File "C:\Python34\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", li
    ne 977, in add
        dists.sort(key=operator.attrgetter('hashcmp'), reverse=True)
    TypeError: unorderable types: str() < NoneType()
    
  2. 在具有管理员权限的 powershell 中运行 (Invoke-WebRequest https://bootstrap.pypa.io/ez_setup.py).Content | python -

    PS C:\Windows\system32> > (Invoke-WebRequest https://bootstrap.pypa.io/ez_setup.py).Content | python -
    Invoke-WebRequest : The response content cannot be parsed because the Internet Explorer engine is not available, or
    Internet Explorer's first-launch configuration is not complete. Specify the UseBasicParsing parameter and try again.
    At line:1 char:4
    + > (Invoke-WebRequest https://bootstrap.pypa.io/ez_setup.py).Content | python -
    +    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotImplemented: (:) [Invoke-WebRequest], NotSupportedException
        + FullyQualifiedErrorId : WebCmdletIEDomNotSupportedException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
    

(我现在不想安装 Internet Explorer,但如果你认为我必须安装,那么我会。)

  1. 下载ez_setup.py 并运行它:

    Installing Setuptools
    running install
    Traceback (most recent call last):
      File "setup.py", line 180, in <module>
        dist = setuptools.setup(**setup_params)
      File "C:\Python34\lib\distutils\core.py", line 148, in setup
        dist.run_commands()
      File "C:\Python34\lib\distutils\dist.py", line 955, in run_commands
        self.run_command(cmd)
      File "C:\Python34\lib\distutils\dist.py", line 974, in run_command
        cmd_obj.run()
      File "C:\Users\a\AppData\Local\Temp\tmpo7o_bqrd\setuptools-11.3.1\setuptools\c
    ommand\install.py", line 67, in run
        self.do_egg_install()
      File "C:\Users\a\AppData\Local\Temp\tmpo7o_bqrd\setuptools-11.3.1\setuptools\c
    ommand\install.py", line 103, in do_egg_install
        cmd.ensure_finalized()  # finalize before bdist_egg munges install cmd
      File "C:\Python34\lib\distutils\cmd.py", line 107, in ensure_finalized
        self.finalize_options()
      File "C:\Users\a\AppData\Local\Temp\tmpo7o_bqrd\setuptools-11.3.1\setuptools\c
    ommand\easy_install.py", line 319, in finalize_options
        self.index_url, search_path=self.shadow_path, hosts=hosts,
      File "C:\Users\a\AppData\Local\Temp\tmpo7o_bqrd\setuptools-11.3.1\setuptools\p
    ackage_index.py", line 269, in __init__
        Environment.__init__(self,*args,**kw)
      File "C:\Users\a\AppData\Local\Temp\tmpo7o_bqrd\setuptools-11.3.1\pkg_resource
    s\__init__.py", line 975, in __init__
        self.scan(search_path)
      File "C:\Users\a\AppData\Local\Temp\tmpo7o_bqrd\setuptools-11.3.1\pkg_resource
    s\__init__.py", line 1005, in scan
        self.add(dist)
      File "C:\Users\a\AppData\Local\Temp\tmpo7o_bqrd\setuptools-11.3.1\pkg_resource
    s\__init__.py", line 1025, in add
        dists.sort(key=operator.attrgetter('hashcmp'), reverse=True)
    TypeError: unorderable types: str() < NoneType()
    Something went wrong during the installation.
    See the error message above.
    
  2. 通过运行 python-3.4.2.msi 并选择修复选项来修复 python 安装。但仍然没有设置工具:

    >pip install scipy -U
    Collecting scipy from https://pypi.python.org/packages/source/s/scipy/
    .0.tar.gz#md5=639112f077f0aeb6d80718dc5019dc7a
      Using cached scipy-0.15.0.tar.gz
      setuptools must be installed to install from a source distribution
    

我认为卸载并重新安装 python 可以解决问题,但在尝试之前,我想也许您可以帮助我找到问题的原因以及解决此问题的正确方法。谢谢。

【问题讨论】:

  • 显然ez_setup.py 文件适用于Python 2,其中'' &lt; ()True,即不是错误。
  • 这是建议的文件here。你知道我在哪里可以找到 Python 3 版本吗?

标签: python setuptools


【解决方案1】:

通过此处建议的更改,我能够解决我的问题(在 Win 8.1 64 位、Python 3.4.2 上):

https://bitbucket.org/pypa/setuptools/pull-request/122/ensure-py_version-and-platform-are-str-in/diff#chg-pkg_resources/init.py

【讨论】:

    【解决方案2】:

    不要下载ez_setup.py,而是使用get-pip.py。从docs开始,如果setuptools没有安装,会先安装。


    由于您仍然遇到错误,请尝试从 Christoph Gohlke 的 Windows 存储库的 Python 扩展包安装 pipsetuptools。确保下载 Python 3.4 的 32 位安装程序。下载后,运行.exe 文件,希望一切都能恢复正常。那里有大量的科学计算包,所以如果你想要 numpy 与 Intel 的 MKL 链接,以及使用增强版 numpy 的 scipy,请继续!

    【讨论】:

      【解决方案3】:

      在我看来,我的 python 安装完全搞砸了。它可能与几周前在我的系统上临时安装 python 2 有关。无论如何,我认为卸载并重新安装整个东西会更容易。所以我卸载了python然后重新安装,但即使这样还不够。最后,我手动删除了C:\Python34并重新安装了python,现在它可以正常工作了。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2016-03-19
        • 2013-01-30
        • 2020-04-27
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多