Python, virtualenv: Getting permission error while activating
Question: I have been given a laptop. So I copied from my Work PC `.virtualenvs/`
directory to my NAS and then I copied it back to my new laptop.

I installed `virtualenv` and `virtualenvwrapper` but I can't get my virtual
environment to work. This is what I got at first:

    
    
    chris@chris-amilo ~ $ workon iwidget
    virtualenvwrapper.user_scripts could not run "/home/chris/.virtualenvs/preactivate": [Errno 13] Permission denied
    virtualenvwrapper.user_scripts could not run "/home/chris/.virtualenvs/iwidget/bin/preactivate": [Errno 13] Permission denied
    

then I did a chmod +x to those files. Although I could change to this
environment after, no library can be seen.

I also get this:

    
    
    chris@chris-amilo ~ $ ./.virtualenvs/iwidget/bin/activate
    bash: ./.virtualenvs/iwidget/bin/activate: Permission denied
    

Also, the following shows that although I can `workon` on certain env, nothing
can be imported: (after I did a chmod +x to preactivate files)

    
    
    chris@chris-amilo ~ $ workon iwidget
    (iwidget)chris@chris-amilo ~ $ python 
    Python 2.7.6 (default, Mar 22 2014, 22:59:56) 
    [GCC 4.8.2] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import pytz
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    ImportError: No module named pytz
    >>> 
    (iwidget)chris@chris-amilo ~ $ ls .virtualenvs/iwidget/lib/python2.7/site-packages/py
    py4j/                               pytz/
    py4j-0.8.1-py2.7.egg-info/          pytz-2014.2-py2.7.egg-info/
    python_dateutil-2.2-py2.7.egg-info/ 
    

How can I fix this?


Answer: Moving virtualenvs is tricky. It's a much better bet to rebuild them from
scratch on the new machine. If you're using a requirements file, this is
trivial: just do `pip install -r requirements.txt`. If you're not using one,
create it on the old machine with `pip freeze > requirements.txt`.

