• pip安装第三方包失败


    一、更新pip和setuptools工具

      >>> sudo pip install pip -U

      >>> sudo pip install setuptools -U

    如果上一步执行后,还是安装不了,就执行第二步

    二、仔细查看错误信息,寻找缺失的依赖项,安装了缺失的依赖项后,再进行安装

    例如:

    pip install --user mmcv  --trusted-host yum.tbsite.net
    Looking in indexes: http://yum.tbsite.net/pypi/simple/
    Collecting mmcv
      Downloading http://yum.tbsite.net/pypi/packages/26/fa/f032c1e0095b4dfac42feae2f4e8ad77dd3ad83257cb5269814c583ac34c/mmcv-0.2.14.tar.gz (48kB)
         |████████████████████████████████| 51kB 19.6MB/s
        ERROR: Command errored out with exit status 1:
         command: /opt/conda/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-td71coct/mmcv/setup.py'"'"'; __file__='"'"'/tmp/pip-install-td71coct/mmcv/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'
    '"'"', '"'"'
    '"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-td71coct/mmcv/pip-egg-info
             cwd: /tmp/pip-install-td71coct/mmcv/
        Complete output (33 lines):
        WARNING: The repository located at yum.tbsite.net is not a trusted or secure host and is being ignored. If this repository is available via HTTPS we recommend you use HTTPS instead, otherwise you may silence this warning and allow it anyway with '--trusted-host yum.tbsite.net'.
        ERROR: Could not find a version that satisfies the requirement pytest-runner (from versions: none)
        ERROR: No matching distribution found for pytest-runner
        Traceback (most recent call last):
          File "/home/admin/.local/lib/python3.6/site-packages/setuptools/installer.py", line 119, in fetch_build_egg
            subprocess.check_call(cmd)
          File "/opt/conda/lib/python3.6/subprocess.py", line 291, in check_call
            raise CalledProcessError(retcode, cmd)
        subprocess.CalledProcessError: Command '['/opt/conda/bin/python', '-m', 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w', '/tmp/tmp8ffnblrb', '--quiet', '--index-url', 'http://yum.tbsite.net/pypi/simple', 'pytest-runner']' returned non-zero exit status 1.
    
        During handling of the above exception, another exception occurred:
    
        Traceback (most recent call last):
          File "<string>", line 1, in <module>
          File "/tmp/pip-install-td71coct/mmcv/setup.py", line 83, in <module>
            zip_safe=False)
          File "/home/admin/.local/lib/python3.6/site-packages/setuptools/__init__.py", line 144, in setup
            _install_setup_requires(attrs)
          File "/home/admin/.local/lib/python3.6/site-packages/setuptools/__init__.py", line 139, in _install_setup_requires
            dist.fetch_build_eggs(dist.setup_requires)
          File "/home/admin/.local/lib/python3.6/site-packages/setuptools/dist.py", line 721, in fetch_build_eggs
            replace_conflicting=True,
          File "/home/admin/.local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 782, in resolve
            replace_conflicting=replace_conflicting
          File "/home/admin/.local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 1065, inbest_match
            return self.obtain(req, installer)
          File "/home/admin/.local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 1077, inobtain
            return installer(requirement)
          File "/home/admin/.local/lib/python3.6/site-packages/setuptools/dist.py", line 777, in fetch_build_egg
            return fetch_build_egg(self, req)
          File "/home/admin/.local/lib/python3.6/site-packages/setuptools/installer.py", line 121, in fetch_build_egg
            raise DistutilsError(str(e))
        distutils.errors.DistutilsError: Command '['/opt/conda/bin/python', '-m', 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w', '/tmp/tmp8ffnblrb', '--quiet', '--index-url', 'http://yum.tbsite.net/pypi/simple', 'pytest-runner']' returned non-zero exit status 1.
        ----------------------------------------
    ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output

    对于上面这个错误,通过阅读错误提示发现,少了一个依赖项pytest-runner

    WARNING: The repository located at yum.tbsite.net is not a trusted or secure host and is being ignored. If this repository is available via HTTPS we recommend you use HTTPS instead, otherwise you may silence this warning and allow it anyway with '--trusted-host yum.tbsite.net'.
        ERROR: Could not find a version that satisfies the requirement pytest-runner (from versions: none)

    安装了这个依赖项后,再安装mmcv这个第三方包就没问题了。

    三、补充

      导致pip安装第三方包出现错误的原因有很多,比如网络中断、使用国外的python源(下载超时)等等。

  • 相关阅读:
    loads和dumps的用法
    python实现装饰器
    pycharm 配置 git 方法
    正则表达式——练习一
    fiddler下载安装
    robotframework引入seleniumlibrary报错
    Codeforces-936B Sleepy Game
    Codeforces-940D. Alena And The Heater
    Codeforces-935D. Fafa and Ancient Alphabet
    Java编程规范
  • 原文地址:https://www.cnblogs.com/loveprogramme/p/12579277.html
Copyright © 2020-2023  润新知