Issues

Issue #40 resolved

virtualenvwrapper.sh and $VIRTUALENVWRAPPER_PYTHON

bpursley
created an issue

I am a fan of virtualenv and virtualenvwrapper which I employ on Ubuntu 10.04. I do most of my python development without superuser priveleges in standalone directories (/wpython and /wpydev) I maintain the Ubuntu platform through synaptic to keep it stable and free of development tinkering.

== Problem: == When I open a terminal I am faced with this error message (Snippet 1) from "/wpython/bin/virtualenvwrapper.sh" even though I have no problem finding $VIRTUALENVWRAPPER_PYTHON or importing virtualenvwrapper.hook_loader (Snippet 2). I have included my relevant settings from .bashrc (Snippet 3). What am I doing wrong?

Regards, Bernie Pursley Simsbury, CT

== Snippet 1 (error message) ==

virtualenvwrapper.sh: Could not find Python module virtualenvwrapper.hook_loader using VIRTUALENVWRAPPER_PYTHON=/usr/bin/python. Is the PATH set properly?

bpursley@ub10:~$

== Snippet 2 (but it is there) ==

bpursley@ub10:~$ $VIRTUALENVWRAPPER_PYTHON

Python 2.7a4+ (trunk:79601, Apr 2 2010, 15:03:18) [GCC 4.4.1] on linux2 Type "help", "copyright", "credits" or "license" for more information.

import virtualenvwrapper.hook_loader

==============================

== Snippet 3 (from .bashrc) ==

export WORKON_HOME=/wpydev/virtualenvs

export VIRTUALENVWRAPPER_TMPDIR=/wpydev/virtualenvs/tmp

source /wpython/bin/virtualenvwrapper.sh

export PATH=/wpython/bin/:${PATH}

alias python='python2.7'

export PYTHONPATH=/wpython/lib/python2.7/site-packages:${PYTHONPATH}

export VIRTUALENVWRAPPER_PYTHON=/wpython/bin/python

==============================

Comments (17)

  1. Anonymous

    I had the same issue, and yes, moving:

    export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python2.5

    before sourcing virtualenvwrapper.sh fixes the problem. However, now every time I source virtualenvwrapper.sh, I get output like this:

    /var/folders/Ch/ChDQGdIqGJiZDne2V2ToUU+++TI/-Tmp-/virtualenvwrapper.MPQvhd

    which seems unnecessary.

  2. bpursley reporter

    Sorry - I did not realize that my earlier reply did not update this stream.

    Yes, moving "export VIRTUALENVWRAPPER_PYTHON" before "source virtualenvwrapper.sh" addressed the problem.

    Subject: Re: Issue 40 in virtualenvwrapper: virtualenvwrapper.sh and $VIRTUALENVWRAPPER_PYTHON Date: Tue, 27 Apr 2010 10:45:48 -0400 From: Bernie Pursley <bernie@bpursley.net> To: issues-noreply@reply.bitbucket.org

    Yes, moving "export VIRTUALENVWRAPPER_PYTHON" before "source virtualenvwrapper.sh" addressed the problem.

    Thank you for your help - and thank you for virtualenvwrapper.

    Virtualenv and virtualenvwrapper have made python coding and testing so much easier than what we dealt with before you and Ian shared these tools.

    Regards,

    Bernie Pursley Simsbury, CT

  3. Mark Fink

    I work with Ubuntu 10.04, too In my case a very similar problem was caused by insufficient permissions. I did not copy from the repo, I used pip install.

    cd /usr/local/lib/python2.6/dist-packages

    sudo chmod a+x virtualenvwrapper virtualenvwrapper-2.1.1.egg-info/

    Thanks for virtualenvwrapper, Mark

  4. Anonymous

    I had a problem similar to Mark's. I had to correct the permissions to include read permission for my Ubuntu 10.04 pip install.

    cd /usr/local/lib/python2.6/dist-packages

    sudo chmod a+r virtualenvwrapper virtualenvwrapper-2.1.1-nspkg.pth virtualenvwrapper-2.1.1.egg-info/

  5. Anonymous

    I had this problem even AFTER had removed virtualenv and virtualenvwrapper. It printed out the following twice:

    Traceback (most recent call last): File "<string>", line 1, in <module> ImportError: No module named virtualenvwrapper.hook_loader virtualenvwrapper.sh: There was a problem running the initialization hooks. If Python could not import the module virtualenvwrapper.hook_loader, check that virtualenv has been installed for VIRTUALENVWRAPPER_PYTHON=/usr/bin/python and that PATH is set properly.

    After doing a binary search of my .profile, .bashrc and finally /etc/bash_completion I found a shell variable called $BASH_COMPLETION_COMPAT_DIR that(for me) linked to the directory /etc/bash_completion.d

    Within this folder I found a file called virtualenvwrapper. Upon opening it, it contains nothing. Since this program isn't on my computer any longer I decided to delete it. This resolved my issue. Hooray!

  6. Leandro Boscariol

    I have the same issue:

    $ workon my-env
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
    ImportError: No module named virtualenvwrapper.hook_l
    

    and nothing proposed here worked so far.

    Although I'm using Amazon Linux AMI. Details from python:

    Python 2.7.3 (default, May 18 2012, 22:11:42) 
    [GCC 4.4.6 20110731 (Red Hat 4.4.6-3)] on linux2
    

    Any ideas on what could be?

  7. oppih Xue

    After an upgrade of my system, when I open a new terminal, I always get :

    Traceback (most recent call last):
      File "<string>", line 1, in <module>
    ImportError: No module named virtualenvwrapper.hook_loader
    virtualenvwrapper.sh: There was a problem running the initialization hooks. If Python could not import the module virtualenvwrapper.hook_loader, check that virtualenv has been installed for VIRTUALENVWRAPPER_PYTHON=/usr/bin/python and that PATH is set properly.
    

    Does my system need any other files or modules ?

    I hope someone can help me with it.

  8. Doug Hellmann repo owner

    opplh, did your system upgrade change the version of Python? The hook loader portion of virtualenvwrapper is installed in the python site-packages, but if the version of python changes the files won't be found in their old, version-specific, location. Try re-installing virtualenvwrapper.

  9. Jon Crowell

    I am having a similar issue. Everything was working fine and then I decided to install virtualenvwrapper.django. So I ran the following command: sudo pip install virtualenvwrapper.django

    Now, whenever I log into my terminal I get the following message:

    Traceback (most recent call last): File "<string>", line 1, in <module> ImportError: No module named hook_loader virtualenvwrapper.sh: There was a problem running the initialization hooks.

    If Python could not import the module virtualenvwrapper.hook_loader, check that virtualenv has been installed for VIRTUALENVWRAPPER_PYTHON=/usr/bin/python and that PATH is set properly.

    I'm doing all this on a MacBook and running iTerm2.

    Running "sudo pip install virtualenv" results in the following message:

    Requirement already satisfied (use --upgrade to upgrade): virtualenv in /Library/Python/2.7/site-packages/virtualenv-1.8.2-py2.7.egg Cleaning up...

  10. Doug Hellmann repo owner

    Jon, where is virtualenvwrapper installed and which python appears first in your path? Is it different from the one that appears first in your path under sudo?

  11. Log in to comment