【问题标题】:Python 3.5 pip 9 AttributeError: 'NoneType' object has no attribute 'bytes'Python 3.5 pip 9 AttributeError:“NoneType”对象没有属性“字节”
【发布时间】:2022-02-20 01:40:19
【问题描述】:

有什么问题?我尝试了“python -m pip install -U pip”和“python -m pip install --upgrade pip”都出现相同的错误(和“pip安装 -U --force-reinstall pip")。我该怎么办?

C:\Users\Peyman\PycharmProjects\untitled3>python -m pip install -U pip
Collecting pip
  Using cached https://files.pythonhosted.org/packages/5f/25/e52d3f31441505a5f3af41213346e5b6c221c9e086a166f3703d2ddaf940/pip-18.0-py2.py3-none-any.whl
Installing collected packages: pip
  Found existing installation: pip 9.0.3
    Uninstalling pip-9.0.3:
      Successfully uninstalled pip-9.0.3
  Rolling back uninstall of pip
Exception:
Traceback (most recent call last):
  File "C:\Users\Peyman\AppData\Roaming\Python\Python35\site-packages\pip\basecommand.py", line 215, in main
    status = self.run(options, args)
  File "C:\Users\Peyman\AppData\Roaming\Python\Python35\site-packages\pip\commands\install.py", line 342, in run
    prefix=options.prefix_path,
  File "C:\Users\Peyman\AppData\Roaming\Python\Python35\site-packages\pip\req\req_set.py", line 784, in install
    **kwargs
  File "C:\Users\Peyman\AppData\Roaming\Python\Python35\site-packages\pip\req\req_install.py", line 851, in install
    self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
  File "C:\Users\Peyman\AppData\Roaming\Python\Python35\site-packages\pip\req\req_install.py", line 1064, in move_wheel_files
    isolated=self.isolated,
  File "C:\Users\Peyman\AppData\Roaming\Python\Python35\site-packages\pip\wheel.py", line 462, in move_wheel_files
    generated.extend(maker.make(spec))
  File "C:\Users\Peyman\AppData\Roaming\Python\Python35\site-packages\pip\_vendor\distlib\scripts.py", line 372, in make
    self._make_script(entry, filenames, options=options)
  File "C:\Users\Peyman\AppData\Roaming\Python\Python35\site-packages\pip\_vendor\distlib\scripts.py", line 276, in _make_script
    self._write_script(scriptnames, shebang, script, filenames, ext)
  File "C:\Users\Peyman\AppData\Roaming\Python\Python35\site-packages\pip\_vendor\distlib\scripts.py", line 212, in _write_script
    launcher = self._get_launcher('t')
  File "C:\Users\Peyman\AppData\Roaming\Python\Python35\site-packages\pip\_vendor\distlib\scripts.py", line 351, in _get_launcher
    result = finder(distlib_package).find(name).bytes
AttributeError: 'NoneType' object has no attribute 'bytes'
You are using pip version 9.0.3, however version 18.0 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

【问题讨论】:

    标签: python pip python-3.5


    【解决方案1】:

    尝试使用easy_install -U pip,根据这个bug report

    编辑:好的,转到“https://pypi.org/simple/pip/”,并下载最新的 .whl 文件(滚动到底部)。当你拥有它时,在同一个文件夹中打开 cmd(通过单击文件 -> 在文件资源管理器中打开 powershell/cmd),然后键入

    pip install filename,文件名是你下载的文件名(应该是pip-18.0-py2.py3-none-any.whl)。

    试试看,告诉我它是否有效。

    【讨论】:

    • 我可以运行“python -m easy_install -U pip”并成功升级pip。我发现安装后pip.exe升级了(pip -V显示新版本),但是“python -m pip -V”仍然显示旧版本。无论如何它对我有用!
    • 首先尝试下载*whl文件但没有成功,后来easy_install方法成功了
    • 这很高兴解决了 pip 版本 19.2.1 到 19.2.3 (python 3.7.4) 的问题。
    【解决方案2】:

    您可以尝试以下方法:

    python -m pip install -U --force-reinstall pip
    

    【讨论】:

    • 简单而伟大的解决方案
    【解决方案3】:

    我的答案是 assmmahmud 的变体,但对我来说,我必须使用选项 --user。 我在 Windows 上,所以来自 CMD.exe;

    py -m pip install --user --force-reinstall -U
    

    如果我不使用 --user 选项,则会发生错误。

    【讨论】:

      【解决方案4】:

      the official site 下载get-pip.py 并运行此代码:

      $ python get-pip.py
      

      或者在 Windows 上,这个:

      py get-pip.py
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-04-27
        • 2017-12-28
        • 2017-10-05
        • 2018-03-17
        • 2019-01-10
        • 2013-08-06
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多