【发布时间】:2018-04-28 04:55:23
【问题描述】:
我尝试在托管服务器 (Ubuntu 16.04) 上运行 django 演示项目:它运行良好。 然后我尝试在本地机器上运行相同的代码:
Unhandled exception in thread started by <function wrapper at 0x7fc0c4403f50>
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/django/utils/autoreload.py", line 228, in wrapper
fn(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/runserver.py", line 116, in inner_run
autoreload.raise_last_exception()
File "/usr/local/lib/python2.7/dist-packages/django/utils/autoreload.py", line 251, in raise_last_exception
six.reraise(*_exception)
File "/usr/local/lib/python2.7/dist-packages/django/utils/autoreload.py", line 228, in wrapper
fn(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "/usr/local/lib/python2.7/dist-packages/django/apps/config.py", line 127, in create
import_module(entry)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
ImportError: No module named about
因此,我尝试更新 django 安装(它的版本可能比服务器旧)。
所以我尝试了 pip django 更新:
sudo pip install -U django
导致了这个错误:
The directory '/home/lxuser/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/lxuser/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Requirement already up-to-date: django in /usr/local/lib/python2.7/dist-packages (1.11.12)
Requirement not upgraded as not directly required: pytz in /usr/local/lib/python2.7/dist-packages (from django) (2018.4)
requests 2.18.4 has requirement certifi>=2017.4.17, but you'll have certifi 0.0.8 which is incompatible.
所以我尝试了这个:
sudo -H pip install -U django
现在错误是:
Requirement already up-to-date: django in /usr/local/lib/python2.7/dist-packages (1.11.12)
Requirement not upgraded as not directly required: pytz in /usr/local/lib/python2.7/dist-packages (from django) (2018.4)
requests 2.18.4 has requirement certifi>=2017.4.17, but you'll have certifi 0.0.8 which is incompatible.
所以有错误但Django安装似乎不是太旧。
所以我想问更一般的:
我如何确保 django 版本(以及依赖库) 相同或至少如此相似,以至于我可以运行相同 没有代码不兼容的项目代码?
如何以同步方式更新两个系统(例如托管服务器和本地开发系统)上的版本?
【问题讨论】: