Python ImportError cannot import urandom Since Ubuntu 12.04 upgrade

后端 未结 5 1078
感情败类
感情败类 2020-12-08 00:01

Upgraded Ubuntu to Precise Pangolin (12.04), and Python\'s Random is now broken... I suspect other things might be broken too. How do I fix Python?

    File          


        
5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-08 01:01

    I had the same problem when upgrading to 12.10, and when upgrading to 16.04 (In the 16.04, the message was no module named datetime.)

    To solve it just ran virtualenv over the same installation and it worked. Give it the --no-site-packages flag to preserve your modules:

    $ 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............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
    

    Since I have all of my virtualenvs in the same dir, I just ran:

    $ ls | xargs -I{} virtualenv  --no-site-packages {}
    

提交回复
热议问题