问题描述
刚刚从ubuntu 12.10升级到13.04,并在virtualenv中运行Django站点时获得了此升级
(virtualenv)sysadmin@ubuntu:~/webapps/devsite/djangosite$ ./manage.py runserver
Traceback (most recent call last):
File "./manage.py", line 2, in <module>
from django.core.management import execute_manager
File "/home/sysadmin/webapps/devsite/virtualenv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 7, in <module>
from django.core.management.base import BaseCommand, CommandError, handle_default_options
File "/home/sysadmin/webapps/devsite/virtualenv/local/lib/python2.7/site-packages/django/core/management/base.py", line 14, in <module>
from django.utils.encoding import smart_str
File "/home/sysadmin/webapps/devsite/virtualenv/local/lib/python2.7/site-packages/django/utils/encoding.py", line 4, in <module>
import datetime
ImportError: No module named datetime
最佳办法
做就是了
virtualenv /home/sysadmin/webapps/devsite/virtualenv/
这将在VirtualEnv中重新安装Python,此后它将起作用(并且您无需重新安装库)。
更新:从14.04升级到14.10后,当我处理相同的问题时,virtualenv不想覆盖现有的符号链接到Python,因此我必须先将其删除(在本示例中为rm /home/sysadmin/webapps/devsite/virtualenv/python
)