首页 > 解决方案 > 升级 pip AttributeError 时出错:“NoneType”对象没有属性“字节”

问题描述

我尝试使用以下方法升级 pip:

(venv) C:\Users\Divyanshu Gupta\PycharmProjects\untitled>pip install --upgrade pip
Collecting pip
  Using cached https://files.pythonhosted.org/packages/00/b6/9cfa56b4081ad13874b0c6f96af8ce16cfbc1cb06bedf8e9164ce5551ec1/pip-19.3.1-py2.py3-none-any.whl
Installing collected packages: pip
  Found existing installation: pip 19.0.3
    Uninstalling pip-19.0.3:
      Successfully uninstalled pip-19.0.3
  Rolling back uninstall of pip
  Moving to c:\users\divyanshu gupta\pycharmprojects\untitled\venv\lib\site-packages\pip-19.0.3-py3.8.egg
   from C:\Users\Divyanshu Gupta\PycharmProjects\untitled\venv\Lib\site-packages\~ip-19.0.3-py3.8.egg
  Moving to c:\users\divyanshu gupta\pycharmprojects\untitled\venv\scripts\pip-script.py
   from C:\Users\Divyanshu Gupta\AppData\Local\Temp\pip-uninstall-y1i2neb1\pip-script.py
  Moving to c:\users\divyanshu gupta\pycharmprojects\untitled\venv\scripts\pip.exe
   from C:\Users\Divyanshu Gupta\AppData\Local\Temp\pip-uninstall-y1i2neb1\pip.exe
  Moving to c:\users\divyanshu gupta\pycharmprojects\untitled\venv\scripts\pip.exe.manifest
   from C:\Users\Divyanshu Gupta\AppData\Local\Temp\pip-uninstall-y1i2neb1\pip.exe.manifest
  Moving to c:\users\divyanshu gupta\pycharmprojects\untitled\venv\scripts\pip3-script.py
   from C:\Users\Divyanshu Gupta\AppData\Local\Temp\pip-uninstall-y1i2neb1\pip3-script.py
  Moving to c:\users\divyanshu gupta\pycharmprojects\untitled\venv\scripts\pip3.8-script.py
   from C:\Users\Divyanshu Gupta\AppData\Local\Temp\pip-uninstall-y1i2neb1\pip3.8-script.py
  Moving to c:\users\divyanshu gupta\pycharmprojects\untitled\venv\scripts\pip3.8.exe
   from C:\Users\Divyanshu Gupta\AppData\Local\Temp\pip-uninstall-y1i2neb1\pip3.8.exe
  Moving to c:\users\divyanshu gupta\pycharmprojects\untitled\venv\scripts\pip3.8.exe.manifest
   from C:\Users\Divyanshu Gupta\AppData\Local\Temp\pip-uninstall-y1i2neb1\pip3.8.exe.manifest
  Moving to c:\users\divyanshu gupta\pycharmprojects\untitled\venv\scripts\pip3.exe
   from C:\Users\Divyanshu Gupta\AppData\Local\Temp\pip-uninstall-y1i2neb1\pip3.exe
  Moving to c:\users\divyanshu gupta\pycharmprojects\untitled\venv\scripts\pip3.exe.manifest
   from C:\Users\Divyanshu Gupta\AppData\Local\Temp\pip-uninstall-y1i2neb1\pip3.exe.manifest

我收到以下错误。

Exception:
Traceback (most recent call last):
  File "C:\Users\Divyanshu Gupta\PycharmProjects\untitled\venv\lib\site-packages\pip-19.0.3-py3.8.egg\pip\_internal\cli\base_command.py", line 179, in main
    status = self.run(options, args)
  File "C:\Users\Divyanshu Gupta\PycharmProjects\untitled\venv\lib\site-packages\pip-19.0.3-py3.8.egg\pip\_internal\commands\install.py", line 384, in run
    installed = install_given_reqs(
  File "C:\Users\Divyanshu Gupta\PycharmProjects\untitled\venv\lib\site-packages\pip-19.0.3-py3.8.egg\pip\_internal\req\__init__.py", line 53, in install_given_reqs
    requirement.install(
  File "C:\Users\Divyanshu Gupta\PycharmProjects\untitled\venv\lib\site-packages\pip-19.0.3-py3.8.egg\pip\_internal\req\req_install.py", line 910, in install
    self.move_wheel_files(
  File "C:\Users\Divyanshu Gupta\PycharmProjects\untitled\venv\lib\site-packages\pip-19.0.3-py3.8.egg\pip\_internal\req\req_install.py", line 437, in move_wheel_files
    move_wheel_files(
  File "C:\Users\Divyanshu Gupta\PycharmProjects\untitled\venv\lib\site-packages\pip-19.0.3-py3.8.egg\pip\_internal\wheel.py", line 544, in move_wheel_files
    generated.extend(maker.make(spec))
  File "C:\Users\Divyanshu Gupta\PycharmProjects\untitled\venv\lib\site-packages\pip-19.0.3-py3.8.egg\pip\_vendor\distlib\scripts.py", line 405, in make
    self._make_script(entry, filenames, options=options)
  File "C:\Users\Divyanshu Gupta\PycharmProjects\untitled\venv\lib\site-packages\pip-19.0.3-py3.8.egg\pip\_vendor\distlib\scripts.py", line 309, in _make_script
    self._write_script(scriptnames, shebang, script, filenames, ext)
  File "C:\Users\Divyanshu Gupta\PycharmProjects\untitled\venv\lib\site-packages\pip-19.0.3-py3.8.egg\pip\_vendor\distlib\scripts.py", line 245, in _write_script
    launcher = self._get_launcher('t')
  File "C:\Users\Divyanshu Gupta\PycharmProjects\untitled\venv\lib\site-packages\pip-19.0.3-py3.8.egg\pip\_vendor\distlib\scripts.py", line 384, in _get_launcher
    result = finder(distlib_package).find(name).bytes
AttributeError: 'NoneType' object has no attribute 'bytes'

我今天只安装了 python 和 pycharm,这是我在 python 中尝试做的第一件事。pip install 既不更新,我也无法使用 pip install 命令安装任何其他软件包,例如“pygame”。

标签: pythonpython-3.xpippycharm

解决方案


您可能已经安装了不同的 pip 版本,这可能是导致问题的原因。
您应该尝试找到它的安装位置并删除任何与 pip 相关的内容。

尝试键入pip -V以检查 cmd 上的版本和路径。在 python 文件夹中,尝试删除其他版本的 pip。如果情况仍然存在,请使用 easy_install 更新 pip。例如easy_install -U pip
对于具有类似回溯检查的错误:this


推荐阅读