22

刚刚从 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
4

1 回答 1

43

做就是了

virtualenv /home/sysadmin/webapps/devsite/virtualenv/

这将在 VirtualEnv 中重新安装 Python,之后它将工作(您不需要重新安装库)。


更新:当我从 14.04 升级到 14.10 后处理同样的问题时,virtualenv 不想覆盖现有的 Python 符号链接,所以我必须先将其删除(在这个例子中是rm /home/sysadmin/webapps/devsite/virtualenv/python

于 2013-04-29T13:42:27.410 回答