【发布时间】:2019-12-23 21:50:29
【问题描述】:
我正在用 ubuntu 运行 VPS:
Distributor ID: Ubuntu
Description: Ubuntu 14.04.5 LTS
Release: 14.04
Codename: trusty
我尝试将 Python 从 2.7.6 升级到 2.7.16。
刚升级 Gunicorn 库后启动失败
Traceback (most recent call last):
File "/home/user/bin/python-2.7/bin/gunicorn", line 7, in <module>
from gunicorn.app.wsgiapp import run
File "/home/user/bin/python-2.7/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 9, in <module>
from gunicorn.app.base import Application
File "/home/user/bin/python-2.7/lib/python2.7/site-packages/gunicorn/app/base.py", line 12, in <module>
from gunicorn import util
File "/home/user/bin/python-2.7/lib/python2.7/site-packages/gunicorn/util.py", line 12, in <module>
import pkg_resources
File "/home/user/bin/python-2.7/lib/python2.7/site-packages/pkg_resources/__init__.py", line 82, in <module>
__import__('pkg_resources.extern.packaging.requirements')
File "/home/user/bin/python-2.7/lib/python2.7/site-packages/pkg_resources/extern/__init__.py", line 61, in load_module
"distribution.".format(**locals())
ImportError: The 'packaging.requirements' package is required; normally this is bundled with this package so if you get this warning, consult the packager of your distribution.
我被告知这可能是一些 setuptools 问题,所以我更新了它们
python -m ensurepip
Looking in links: /tmp/tmp98U8zf
Requirement already satisfied: setuptools in ./bin/python-2.7/lib/python2.7/site-packages (41.1.0)
Requirement already satisfied: pip in ./bin/python-2.7/lib/python2.7/site-packages (19.2.2)
(没有变化)
我试过了
pip install packaging
(没有变化)
或将 setuptools 降级到 19.2(如 Python 2.7 The 'packaging' package is required; normally this is bundled with this package 中的建议)
得到了
File "/home/user/bin/python-2.7/lib/python2.7/site-packages/gunicorn/config.py", line 8, in <module>
import copy
File "/home/user/bin/python-2.7/lib/python2.7/copy.py", line 52, in <module>
import weakref
File "/home/user/bin/python-2.7/lib/python2.7/weakref.py", line 14, in <module>
from _weakref import (
ImportError: cannot import name _remove_dead_weakref
在我的情况下,有什么可行的方法可以升级到 2.7.16 python?
UPD:
我用它升级了python
wget https://www.python.org/ftp/python/2.7.16/Python-2.7.16.tgz
make clean && ./configure --enable-unicode=ucs4 --enable-shared --prefix=/home/user/bin/python-2.7/ --with-ensurepip=install && make && make install
pip install -r ~/django/django_projects/requirements.txt
点冻结:https://www.pastiebin.com/5d592ea701503
谢谢。
【问题讨论】:
-
你是如何升级你的python的?
-
你的 pip freeze 显示什么?
-
@Mox 我在帖子底部添加了详细信息。
-
我建议你创建一个单独的虚拟机并使用 pyenv 来配置你的 python 版本,看看是否会发生同样的问题。这只是为了确保问题与您在 ubuntu 上升级 python 的方式无关
-
尝试从系统中清除 pip 并使用 recommended method 重新安装它。
标签: python python-2.7 gunicorn setuptools