ubuntu 升级python3.6后pip install 报错处理

python3.5升级3.6后 pip报错问题

pip报错

如果python成功升级后,发现pip 命令 报错,那么需要先卸载

apt-get remove python3-pip

apt-get autoremove

接着重新安装pip
sudo apt-get install python3-pip

安装完成pip后 有可能提示版本过低,那么需要执行升级
python3 -m pip install --upgrade pip

搞完后,查看pip版本
pip version, 如果pip命令没有,则试试pip3命令

pip install 时如果出现以下报错时, 需要升级 setuptools,升级后应该就正常了。不知道为什么 这块报错 网上搜索到的比较少。

pip install --upgrade setuptools

WARNING: Discarding https://pypi.tuna.tsinghua.edu.cn/packages/72/bb/8d72cfbd17f8353391ed8ba14c090f090df9cccdc31f3c624aa2e67cdcd6/adbutils-0.10.1.tar.gz#sha256=abdc72c15ec55b3a32821fabdd3456852d4d5fe5b5142a277bdb543e8efc0364 (from https://pypi.tuna.tsinghua.edu.cn/simple/adbutils/) (requires-python:>=3.5). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/9a/b9/93d42ca00ede42b447552fbb7d12fa9aa7b99d502e72d364d3f748033d63/adbutils-0.10.0.tar.gz (159 kB)
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3 -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-qdqpj0u8/adbutils_fe3e044961124543b6d7dc8a8fb14c19/setup.py'"'"'; __file__='"'"'/tmp/pip-install-qdqpj0u8/adbutils_fe3e044961124543b6d7dc8a8fb14c19/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-nnw8hz66
         cwd: /tmp/pip-install-qdqpj0u8/adbutils_fe3e044961124543b6d7dc8a8fb14c19/
    Complete output (17 lines):
    Couldn't find index page for 'pbr' (maybe misspelled?)
    No local packages or working download links found for pbr
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-qdqpj0u8/adbutils_fe3e044961124543b6d7dc8a8fb14c19/setup.py", line 19, in <module>
        setuptools.setup(setup_requires=['pbr'], python_requires='>=3.5', pbr=True)
      File "/usr/lib/python3.6/distutils/core.py", line 108, in setup
        _setup_distribution = dist = klass(attrs)
      File "/usr/local/lib/python3.6/dist-packages/setuptools-33.1.1-py3.6.egg/setuptools/dist.py", line 317, in __init__
      File "/usr/local/lib/python3.6/dist-packages/setuptools-33.1.1-py3.6.egg/setuptools/dist.py", line 372, in fetch_build_eggs
      File "/usr/local/lib/python3.6/dist-packages/setuptools-33.1.1-py3.6.egg/pkg_resources/__init__.py", line 846, in resolve
      File "/usr/local/lib/python3.6/dist-packages/setuptools-33.1.1-py3.6.egg/pkg_resources/__init__.py", line 1118, in best_match
      File "/usr/local/lib/python3.6/dist-packages/setuptools-33.1.1-py3.6.egg/pkg_resources/__init__.py", line 1130, in obtain
      File "/usr/local/lib/python3.6/dist-packages/setuptools-33.1.1-py3.6.egg/setuptools/dist.py", line 440, in fetch_build_egg
      File "/usr/local/lib/python3.6/dist-packages/setuptools-33.1.1-py3.6.egg/setuptools/command/easy_install.py", line 668, in easy_install
    distutils.errors.DistutilsError: Could not find suitable distribution for Requirement.parse('pbr')
    setup.py arguments: ['/tmp/pip-install-qdqpj0u8/adbutils_fe3e044961124543b6d7dc8a8fb14c19/setup.py', 'egg_info', '--egg-base', '/tmp/pip-pip-egg-info-nnw8hz66']
    ----------------------------------------

参考

  1. https://www.cnblogs.com/dancesir/p/14201267.html
  2. https://stackoverflow.com/questions/61525119/error%2Dcommand%2Derrored%2Dout%2Dwith%2Dexit%2Dstatus%2D1%2Dpip%2Dinstall
  3. https://zhuanlan.zhihu.com/p/165909343
### 更新 Python 3.6 中的 pip 至最新版本 为了确保 `pip` 能够正常工作并更新到最新版本,在 Ubuntu 或其他 Linux 发行版中可以按照如下方法操作: 对于已经安装了特定版本 Python 的情况,比如 Python 3.6,可以通过下载官方提供的脚本来获取最新的 `pip` 版本。具体来说,可以从 PyPA (Python Packaging Authority) 获取 `get-pip.py` 文件来完成这一过程[^2]。 ```bash wget https://bootstrap.pypa.io/get-pip.py sudo python3.6 get-pip.py ``` 上述命令会自动检测当前系统的 Python 解释器,并为指定版本(这里是 Python 3.6)安装或升级相应的 `pip` 工具。这一步骤能够解决由于不同版本之间冲突引起的问题,如之前遇到过的在Ubuntu中将Python 3.4升级Python 3.6时发生的中断现象[^1]。 另外一种方式是在现有环境中直接通过已有的 `pip` 来进行自我更新: ```bash python3.6 -m pip install --upgrade pip ``` 这种方法适用于那些已经有旧版本 `pip` 安装的情况。它利用 `-m` 参数调用了 Python 模块的方式执行 `pip` 自身作为模块来进行更新动作。 最后确认 `pip` 是否成功更新到了预期版本: ```bash pip3.6 --version ``` 此命令用于验证所使用的 `pip` 是不是对应于 Python 3.6 并且显示其具体的版本号。 #### 注意事项 当更改系统中的 Python 默认链接指向新版本时可能会导致某些依赖原生 Python 版本的应用出现问题,因此建议不要轻易改变 `/usr/bin/python3` 这样的全局符号链接[^3]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值