V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
ossphil
V2EX  ›  Python

如何自动探测、删除废弃的包

  •  
  •   ossphil · 2019-08-08 11:50:10 +08:00 · 1782 次点击
    这是一个创建于 1960 天前的主题,其中的信息可能已经有所发展或是发生改变。

    使用命令pip3 freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 sudo -H pip3 install -U更新系统安装的包,但是出现了很多类似的错误:

    Exception:
    Traceback (most recent call last):
      File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 215, in main
        status = self.run(options, args)
      File "/usr/lib/python3/dist-packages/pip/commands/install.py", line 353, in run
        wb.build(autobuilding=True)
      File "/usr/lib/python3/dist-packages/pip/wheel.py", line 749, in build
        self.requirement_set.prepare_files(self.finder)
      File "/usr/lib/python3/dist-packages/pip/req/req_set.py", line 380, in prepare_files
        ignore_dependencies=self.ignore_dependencies))
      File "/usr/lib/python3/dist-packages/pip/req/req_set.py", line 487, in _prepare_file
        req_to_install, finder)
      File "/usr/lib/python3/dist-packages/pip/req/req_set.py", line 428, in _check_skip_installed
        req_to_install, upgrade_allowed)
      File "/usr/lib/python3/dist-packages/pip/index.py", line 465, in find_requirement
        all_candidates = self.find_all_candidates(req.name)
      File "/usr/lib/python3/dist-packages/pip/index.py", line 423, in find_all_candidates
        for page in self._get_pages(url_locations, project_name):
      File "/usr/lib/python3/dist-packages/pip/index.py", line 568, in _get_pages
        page = self._get_page(location)
      File "/usr/lib/python3/dist-packages/pip/index.py", line 683, in _get_page
        return HTMLPage.get_page(link, session=self.session)
      File "/usr/lib/python3/dist-packages/pip/index.py", line 795, in get_page
        resp.raise_for_status()
      File "/usr/share/python-wheels/requests-2.18.4-py2.py3-none-any.whl/requests/models.py", line 935, in raise_for_status
        raise HTTPError( http_error_msg, response=self)
    requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://pypi.org/simple/apturl/
    

    请问这是由于这些包被废弃了吗?那么有没有办法一次性把这些包都删除了?不影响依赖的前提下。

    1 条回复    2019-08-08 15:25:46 +08:00
    frostming
        1
    frostming  
       2019-08-08 15:25:46 +08:00
    优化下你的命令:

    pip list --local --outdated --format freeze | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 sudo -H pip3 install -U
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1445 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 21ms · UTC 17:16 · PVG 01:16 · LAX 09:16 · JFK 12:16
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.