安装 setuptools 时出错(不可排序的类型:str() <NoneType()) [英] Error in installing setuptools (unorderable types: str() &lt; NoneType())

查看:79
本文介绍了安装 setuptools 时出错(不可排序的类型:str() <NoneType())的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Python 3.4.2,32 位 - Win 8.1,64 位

Python 3.4.2, 32 bit - Win 8.1, 64 bit

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

First I was trying to upgrade setuptools, but it was not successful. So I decided to uninstall the previous version. Now I can't install setuptools. I have tried the following:

  1. pip 安装设置工具:

  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()

  • 运行 (Invoke-WebRequest https://bootstrap.pypa.io/ez_setup.py).Content |python - 在具有管理员权限的 powershell 中:

  • Running (Invoke-WebRequest https://bootstrap.pypa.io/ez_setup.py).Content | python - in a powershell with admin privileges:

    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,但如果您认为我必须安装,那么我会安装.)

    (I'm not willing to install Internet Explorer right now, but if you think I have to, then I will.)

    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.
    

  • 通过运行 python-3.4.2.msi 并选择修复选项来修复 python 安装.但仍然没有设置工具:

  • Repairing python installation by running python-3.4.2.msi and choosing the repair option. But still no setuptools:

    >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 可以解决问题,但在尝试之前,我想也许您可以帮助我找到问题的原因以及解决此问题的正确方法.谢谢.

    I think uninstalling and reinstalling python would fix the problem, but before trying that I thought maybe you can help me to find the cause of the problem and the right way to fix this. Thanks.

    推荐答案

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

    I was able to solve my problem (on Win 8.1 64bit, Python 3.4.2) with the change suggested here:

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

    这篇关于安装 setuptools 时出错(不可排序的类型:str() <NoneType())的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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