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
wsds
V2EX  ›  Python

ubuntu 升级了 python3.7 后, pip3 运行报错,且无法安装,找不到解决办法

  •  
  •   wsds · 2018-08-13 18:15:58 +08:00 · 11204 次点击
    这是一个创建于 2321 天前的主题,其中的信息可能已经有所发展或是发生改变。

    请教一下各位大神,怎么解决这个

    root:~# pip3
    Traceback (most recent call last):
      File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 574, in _build_master
        ws.require(__requires__)
      File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 892, in require
        needed = self.resolve(parse_requirements(requirements))
      File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 783, in resolve
        raise VersionConflict(dist, req).with_context(dependent_req)
    pkg_resources.VersionConflict: (pip 10.0.1 (/usr/local/lib/python3.7/site-packages), Requirement.parse('pip==8.0.2'))
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/usr/local/bin/pip", line 5, in <module>
        from pkg_resources import load_entry_point
      File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3088, in <module>
        @_call_aside
      File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3072, in _call_aside
        f(*args, **kwargs)
      File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3101, in _initialize_master_working_set
        working_set = WorkingSet._build_master()
      File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 576, in _build_master
        return cls._build_from_requirements(__requires__)
      File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 589, in _build_from_requirements
        dists = ws.resolve(reqs, Environment())
      File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 778, in resolve
        raise DistributionNotFound(req, requirers)
    pkg_resources.DistributionNotFound: The 'pip==8.0.2' distribution was not found and is required by the application
    
    
    第 1 条附言  ·  2018-08-13 20:26:44 +08:00
    解决了。。。日狗的,一步一个坑,多谢各位
    11 条回复    2018-08-14 10:22:18 +08:00
    meowoo
        1
    meowoo  
       2018-08-13 18:18:20 +08:00 via iPhone
    pip 版本不对? 下个最新的试试
    chenqh
        2
    chenqh  
       2018-08-13 18:19:21 +08:00
    python -m pip?
    wsds
        3
    wsds  
    OP
       2018-08-13 18:25:28 +08:00
    @chenqh
    root:~# python -m pip install -U pip
    Exception:
    Traceback (most recent call last):
    File "/usr/local/lib/python2.7/dist-packages/pip/_internal/basecommand.py", line 228, in main
    status = self.run(options, args)
    File "/usr/local/lib/python2.7/dist-packages/pip/_internal/commands/install.py", line 241, in run
    with self._build_session(options) as session:
    File "/usr/local/lib/python2.7/dist-packages/pip/_internal/basecommand.py", line 81, in _build_session
    insecure_hosts=options.trusted_hosts,
    File "/usr/local/lib/python2.7/dist-packages/pip/_internal/download.py", line 338, in __init__
    self.headers["User-Agent"] = user_agent()
    File "/usr/local/lib/python2.7/dist-packages/pip/_internal/download.py", line 101, in user_agent
    zip(["name", "version", "id"], distro.linux_distribution()),
    File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/distro.py", line 120, in linux_distribution
    return _distro.linux_distribution(full_distribution_name)
    File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/distro.py", line 634, in linux_distribution
    self.version(),
    File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/distro.py", line 688, in version
    self.lsb_release_attr('release'),
    File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/distro.py", line 836, in lsb_release_attr
    return self._lsb_release_info.get(attribute, '')
    File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/distro.py", line 522, in __get__
    ret = obj.__dict__[self._fname] = self._f(obj)
    File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/distro.py", line 933, in _lsb_release_info
    stdout = subprocess.check_output(cmd, stderr=devnull)
    File "/usr/lib/python2.7/subprocess.py", line 574, in check_output
    raise CalledProcessError(retcode, cmd, output=output)
    CalledProcessError: Command '('lsb_release', '-a')' returned non-zero exit status 1
    Traceback (most recent call last):
    File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
    File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
    File "/usr/local/lib/python2.7/dist-packages/pip/__main__.py", line 19, in <module>
    sys.exit(_main())
    File "/usr/local/lib/python2.7/dist-packages/pip/_internal/__init__.py", line 246, in main
    return command.main(cmd_args)
    File "/usr/local/lib/python2.7/dist-packages/pip/_internal/basecommand.py", line 264, in main
    timeout=min(5, options.timeout)) as session:
    File "/usr/local/lib/python2.7/dist-packages/pip/_internal/basecommand.py", line 81, in _build_session
    insecure_hosts=options.trusted_hosts,
    File "/usr/local/lib/python2.7/dist-packages/pip/_internal/download.py", line 338, in __init__
    self.headers["User-Agent"] = user_agent()
    File "/usr/local/lib/python2.7/dist-packages/pip/_internal/download.py", line 101, in user_agent
    zip(["name", "version", "id"], distro.linux_distribution()),
    File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/distro.py", line 120, in linux_distribution
    return _distro.linux_distribution(full_distribution_name)
    File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/distro.py", line 634, in linux_distribution
    self.version(),
    File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/distro.py", line 688, in version
    self.lsb_release_attr('release'),
    File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/distro.py", line 836, in lsb_release_attr
    return self._lsb_release_info.get(attribute, '')
    File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/distro.py", line 522, in __get__
    ret = obj.__dict__[self._fname] = self._f(obj)
    File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/distro.py", line 933, in _lsb_release_info
    stdout = subprocess.check_output(cmd, stderr=devnull)
    File "/usr/lib/python2.7/subprocess.py", line 574, in check_output
    raise CalledProcessError(retcode, cmd, output=output)
    subprocess.CalledProcessError: Command '('lsb_release', '-a')' returned non-zero exit status 1
    wsds
        4
    wsds  
    OP
       2018-08-13 18:27:56 +08:00
    root:~# sudo apt-get install python3-pip
    sudo: unable to resolve host mycloud
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    python3-pip is already the newest version (8.1.1-2ubuntu0.4).
    0 upgraded, 0 newly installed, 0 to remove and 175 not upgraded.
    1 not fully installed or removed.
    After this operation, 0 B of additional disk space will be used.
    chenqh
        5
    chenqh  
       2018-08-13 18:45:48 +08:00
    @wsds 我说的是 python3.7 的那个 python, 你这个用的是 python2.7 版本, 你可以用 python -m pip 来安装包
    wsds
        6
    wsds  
    OP
       2018-08-13 19:04:48 +08:00
    @chenqh 装不了,一样报错
    ysc3839
        7
    ysc3839  
       2018-08-13 19:12:17 +08:00 via Android
    @wsds 4# 1 not fully installed or removed.
    有个软件安装失败了?建议你重装系统。
    另外,你是怎么升级 Python 3.7 的?
    wsds
        8
    wsds  
    OP
       2018-08-13 19:54:54 +08:00
    @ysc3839 为了一个 python 我重装系统,这成本有点高
    直接了编译安装的
    ysc3839
        9
    ysc3839  
       2018-08-13 20:28:49 +08:00
    @wsds 编译安装一般不会装到系统里面的,会装到用户目录或者 /opt 下面。
    而且 Ubuntu 都有 Python 的 ppa 源。
    https://launchpad.net/~deadsnakes/+archive/ubuntu/ppa
    hailinxyz
        10
    hailinxyz  
       2018-08-13 21:03:41 +08:00 via Android
    可能是那条命令里面的 py 环境是指向 2,修改下试试
    likuku
        11
    likuku  
       2018-08-14 10:22:18 +08:00
    所以,系统自带的 python 就不要乱动,想用其他版本,那就用 pyenv 好了。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2092 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 00:47 · PVG 08:47 · LAX 16:47 · JFK 19:47
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.