pip版本低无法升级问题

2 篇文章 1 订阅

最近项目需要,在研究rk1808的开发环境,搭建环境的时候遇到了pip版本低无法安装好多软件,异常如下:

sudo pip install --upgrade pip
The directory '/home/roc/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/roc/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Exception:
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 209, in main
    status = self.run(options, args)
  File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 317, in run
    requirement_set.prepare_files(finder)
  File "/usr/lib/python2.7/dist-packages/pip/req/req_set.py", line 360, in prepare_files
    ignore_dependencies=self.ignore_dependencies))
  File "/usr/lib/python2.7/dist-packages/pip/req/req_set.py", line 448, in _prepare_file
    req_to_install, finder)
  File "/usr/lib/python2.7/dist-packages/pip/req/req_set.py", line 397, in _check_skip_installed
    finder.find_requirement(req_to_install, self.upgrade)
  File "/usr/lib/python2.7/dist-packages/pip/index.py", line 442, in find_requirement
    all_candidates = self.find_all_candidates(req.name)
  File "/usr/lib/python2.7/dist-packages/pip/index.py", line 400, in find_all_candidates
    for page in self._get_pages(url_locations, project_name):
  File "/usr/lib/python2.7/dist-packages/pip/index.py", line 545, in _get_pages
    page = self._get_page(location)
  File "/usr/lib/python2.7/dist-packages/pip/index.py", line 648, in _get_page
    return HTMLPage.get_page(link, session=self.session)
  File "/usr/lib/python2.7/dist-packages/pip/index.py", line 760, in get_page
    resp.raise_for_status()
  File "/usr/share/python-wheels/requests-2.9.1-py2.py3-none-any.whl/requests/models.py", line 840, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
HTTPError: 404 Client Error: Not Found for url: http://repo.rock-chips.com/pypi/simple/pip/
You are using pip version 8.1.1, however version 21.0 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

陷入死循环中,异常提示使用pip install --upgrade pip即可解决该问题,但是使用pip升级时依然会检查版本。

后来怀疑是ubuntu安装源的问题,切换阿里源/清华源都无法解决。百度出来的解决方案是手动安装

wget https://bootstrap.pypa.io/get-pip.py

 sudo python3 get-pip.py

结果:

sudo python3 get-pip.py --force-reinstall

  File "get-pip.py", line 1
    --2021-01-27 16:20:41--  https://bootstrap.pypa.io/get-pip.py
            ^
SyntaxError: invalid token

当时快崩溃,后来忽然留意到rknn配置环境时新建过pip的conf文件,

/etc/pip.conf

  1. [global]
  2. extra-index-url = http://repo.rock-chips.com/pypi/simple
  3. trusted-host = repo.rock-chips.com

然后查看了下pip下载的原来pkg-resoures中还有没有完全同步的资源

修改如下:

[global]
#index-url=http://mirrors.aliyun.com/pypi/simple/
index-url = https://pypi.python.org/simple/

[install]
#trusted-host=mirrors.aliyun.com
trusted-host=pypi.python.org

将pip的conf中修改源即可,或者直接删除conf文件,重新使用升级命令后升级成功

修改后:

sudo pip install --upgrade pip
The directory '/home/roc/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/roc/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting pip
  Downloading https://files.pythonhosted.org/packages/9e/24/bc928987f35dd0167f21b13a1777c21b9c5917c9894cff93f1c1a6cb8f3b/pip-21.0.tar.gz (1.5MB)
    100% |████████████████████████████████| 1.6MB 28kB/s
Installing collected packages: pip
  Found existing installation: pip 8.1.1
    Not uninstalling pip at /usr/lib/python2.7/dist-packages, outside environment /usr
  Running setup.py install for pip ... done
Successfully installed pip-21.0

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值