ubuntu14通过默认pip安装python插件运行报错问题解决

问题描述

 gunicorn 
Traceback (most recent call last):
  File "/usr/local/bin/gunicorn", line 7, in <module>
    from gunicorn.app.wsgiapp import run
  File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/wsgiapp.py", line 9, in <module>
    from gunicorn.app.base import Application
  File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/base.py", line 38
    print("\nError: %s" % str(e), file=sys.stderr)
                                      ^
SyntaxError: invalid syntax

 pip2.7 
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pkg_resources.py", line 444, in _build_master
    ws.require(__requires__)
  File "/usr/lib/python3/dist-packages/pkg_resources.py", line 725, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/lib/python3/dist-packages/pkg_resources.py", line 632, in resolve
    raise VersionConflict(dist,req) # XXX put more info here
pkg_resources.VersionConflict: (pip 1.5.4 (/usr/lib/python3/dist-packages), Requirement.parse('pip==21.0'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/pip2.7", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2749, in <module>
    working_set = WorkingSet._build_master()
  File "/usr/lib/python3/dist-packages/pkg_resources.py", line 446, in _build_master
    return cls._build_from_requirements(__requires__)
  File "/usr/lib/python3/dist-packages/pkg_resources.py", line 459, in _build_from_requirements
    dists = ws.resolve(reqs, Environment())
  File "/usr/lib/python3/dist-packages/pkg_resources.py", line 628, in resolve
    raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: pip==21.0

经观察是pip的问题

问题解决方法

sudo apt-get remove --purge python-pip
wget https://bootstrap.pypa.io/get-pip.py -o get-pip.py
sudo python get-pip.py install 
sudo pip uninstall -y gunicorn
sudo pip install -y gunicorn
验证
~$ gunicorn 
usage: gunicorn [OPTIONS] [APP_MODULE]
gunicorn: error: No application module specified.

  • 我的微信
  • 这是我的微信扫一扫
  • weinxin
  • 我的微信公众号
  • 我的微信公众号扫一扫
  • weinxin
avatar

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: