xxj*_*jnn 54 python random ubuntu
将Ubuntu升级为Precise Pangolin(12.04),而Python的Random现已被破坏......我怀疑其他事情也可能被打破.我该如何修复Python?
File "/usr/lib/python2.7/random.py", line 47, in <module>
from os import urandom as _urandom
ImportError: cannot import name urandom
Run Code Online (Sandbox Code Playgroud)
唉,可怜的Python!我认识他,随机,一个无限玩笑的模块,最可能的混乱.他曾在他的randint()上忍受了我一千次,现在我的工作空间里有多憎恶!我的异常处理程序在它上升.
编辑在virtualenv中运行
Ada*_*ien 45
这是你的问题吗?
https://bugs.launchpad.net/ubuntu/+source/python-defaults/+bug/989856
似乎是在虚拟环境中运行它引起的,并且有一个解决方法.
顺便说一句,这是谷歌的最佳结果.
bra*_*zzi 36
升级到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
Run Code Online (Sandbox Code Playgroud)
因为我在同一个目录中拥有所有的virtualenvs,所以我跑了:
$ ls | xargs -I{} virtualenv --no-site-packages {}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
19856 次 |
| 最近记录: |