ImportError: cannot import name "urandom"

I get this error when I try to runserver any of my projects while I'm running my virtual env (workon django1.2)

the error :

ImportError: cannot import name "urandom"

after researching the issue I found this:

Warning Python bugfix releases 2.6.8, 2.7.3, 3.1.5 and 3.2.3 include a change that will cause “import random” to fail with “cannot import name urandom” on any virtualenv created on a Unix host with an earlier release of Python 2.6/2.7/3.1/3.2, if the underlying system Python is upgraded. This is due to the fact that a virtualenv uses the system Python’s standard library but contains its own copy of the Python interpreter, so an upgrade to the system Python results in a mismatch between the version of the Python interpreter and the version of the standard library. It can be fixed by removing $ENV/bin/python and re-running virtualenv on the same target directory with the upgraded Python.

but running ENV/bin/python gives me :

bash: ENV/bin/python: No file or directory of this type

Where can I find my virtualen directory?

I understand very little about virtualenvs so please bear with me



You have to recreate your virtual environment.

My guess is that the following has happended:

  1. You created a virtualenv
  2. At some later point in time, the system's Python installation was updated with the urandom security bugfix.
  3. Your virtualenv (created from a previous Python point release) does not work anymore (due to the issue you mention in your question)

The simplest fix is to delete your virtual environment and create a new one:

$ virtualenv VIRTUALENVDIR
$ . VIRTUALENVDIR/bin/activate

# then pip install any required packages, if your project has a requirements.txt file,
# this is simply:
$ pip install -r requirements.txt

# otherwise, you will have to install each package
$ pip install packagename
$ pip install packagename==version

Need Your Help

Use Enum.values in with generic class extending Enum

java generics enums

I am trying to initialise a generic class with all the availables values from an Enum. HEre is how I would like it to work:

How would you sprinkle-in ASP.Net MVC into an existing Web Site Project? visual-studio web-site-project

I have a legacy (haha) ASP.Net Webforms Web Site Project in Visual Studio 2008 SP1, that I would like to gradually introduce some MVC functionality into.