Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

virtualenvwrapper.sh error showing at terminal startup

Tags:

python

linux

As I'm starting to learn Python programming, I installed virtualenvwrapper via these commands:

# Install distribute: http://pypi.python.org/pypi/distribute
wget http://python-distribute.org/distribute_setup.py
sudo python distribute_setup.py

# Install pip http://pypi.python.org/pypi/pip
sudo easy_install pip

# Install virtualenv
sudo pip install virtualenv

# Install virtualenvwrapper
sudo pip install --upgrade virtualenvwrapper
virtualenvwrapper.sh
echo source `which virtualenvwrapper.sh` >> $HOME/.bashrc

# IMPORTANT
# Go to the working directory

# Start a working environment virtualenv
mkvirtualenv <working environment name>

# Install all the requirements for the working environment
pip -E $VIRTUAL_ENV install -r requirements.txt

I've been getting this error every time I open a terminal (via guake)

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python2.6/dist-packages/virtualenvwrapper/hook_loader.py", line 72, in main
    backupCount=1,
  File "/usr/lib/python2.6/logging/handlers.py", line 112, in __init__
    BaseRotatingHandler.__init__(self, filename, mode, encoding, delay)
  File "/usr/lib/python2.6/logging/handlers.py", line 64, in __init__
    logging.FileHandler.__init__(self, filename, mode, encoding, delay)
  File "/usr/lib/python2.6/logging/__init__.py", line 827, in __init__
    StreamHandler.__init__(self, self._open())
  File "/usr/lib/python2.6/logging/__init__.py", line 846, in _open
    stream = open(self.baseFilename, self.mode)
IOError: [Errno 2] No such file or directory: '/home/ahim/$VIRTUALENVWRAPPER_LOG_DIR/hook.log'
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 using Linux Mint 10 64bit GNOME.

Is there any way to solve this error I see in the terminal?

I've tried searching via google but none of them seems to fix this problem.

Thank you in advance.

===Edit===

This is what is written in /home/user/.bashrc

source /usr/local/bin/virtualenvwrapper.sh 2> /dev/null
VIRTUALENVWRAPPER_LOG_DIR=/tmp
export VIRTUALENVWRAPPER_LOG_DIR

Please help :(

like image 255
kohrime Avatar asked Oct 05 '11 07:10

kohrime


People also ask

Where is my virtualenvwrapper?

Location of Environments The variable WORKON_HOME tells virtualenvwrapper where to place your virtual environments. The default is $HOME/. virtualenvs . If the directory does not exist when virtualenvwrapper is loaded, it will be created automatically.

How do I install virtualenvwrapper on Windows?

To install, run one of the following: # using pip pip install virtualenvwrapper-win # using easy_install easy_install virtualenvwrapper-win # from source git clone git://github.com/davidmarble/virtualenvwrapper-win.git cd virtualenvwrapper-win python setup.py install # or pip install .


3 Answers

According to this, it seems to be an error with the APT package on Debian/Ubuntu/Mint.

I have installed virtualenvwrapper through APT first, then removed it and installed it via pip.

apt-get install virtualenvwrapper
apt-get remove virtualenvwrapper
pip install virtualenvwrapper

The APT package has added the file /etc/bash_completion.d/virtualenvwrapper but didn't remove it. This is the file that's causing problems.

The recommended solution is to remove this file and the errors stop appearing. (Weirdly, simply renaming the file was not enough).

like image 170
rahmu Avatar answered Sep 28 '22 07:09

rahmu


For those who come afterwards, I had the same problem on Ubuntu 12 and solved this way:

  1. Switch to correct user:

    su username
    
  2. Make sure your WORKON_HOME variable is set to the path you want it to be (defaults to ~/.virtualenv)

    WORKON_HOME=$HOME/.virtualenv
    
  3. Then add these two lines before your source command:

    export VIRTUALENVWRAPPER_LOG_DIR="$WORKON_HOME"
    export VIRTUALENVWRAPPER_HOOK_DIR="$WORKON_HOME"
    
  4. Then save and re-source your bashrc:

    source ~/.bashrc
    
like image 25
x - y Avatar answered Sep 28 '22 06:09

x - y


I had similar issues. I removed any settings in my ~/.bashrc related to virtualenv, eg:

 # virtualenv
 #export WORKON_HOME=~/virtualenvs
 #source /usr/local/bin/virtualenvwrapper.sh

That fixed the errors.

like image 36
Martlark Avatar answered Sep 28 '22 07:09

Martlark