我在升级到 12.10 和升级到 16.04 时遇到了同样的问题(在 16.04 中,消息是no module named datetime
。)
为了解决这个问题,只需在相同的安装上运行 virtualenv 就可以了。给它一个--no-site-packages
标志来保存你的模块:
$ virtualenv --no-site-packages ~/lib/virtualenv/netunong
Overwriting /home/adam/lib/virtualenv/netunong/lib/python2.7/site.py with new content
New python executable in /home/adam/lib/virtualenv/netunong/bin/python
Installing distribute.....<skippping dots, of course>.......done.
Installing pip................done.
Overwriting /home/adam/lib/virtualenv/netunong/bin/activate with new content
Overwriting /home/adam/lib/virtualenv/netunong/bin/activate_this.py with new content
由于我所有的 virtualenvs 都在同一个目录中,所以我只运行了:
$ ls | xargs -I{} virtualenv --no-site-packages {}