Issues

Issue #95 resolved

error on opening shell

Anonymous created an issue

I have freshly installed virtualenvwrapper in Ubuntu 10.10. Environment is: Python 2.6. and I updated to the most recent versions of pip and virtualenv as well.

I have managed to create an environment, and can activate it. However, each time I open a shell, I get the following:

{{{ 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/maxweld/$VIRTUALENVWRAPPER_LOG_DIR/hook.log' }}}

Have I missed something? Thanks in advance.

Comments (32)

  1. Anonymous

    in .profile I have the following. There is nothing relevant in .bashrc

    # set PYTHONPATH so it includes user's private Python directory if it exists
    if [ -d "$HOME/Python" ] ; then
        export PYTHONPATH="$HOME/Python:$PYTHONPATH"
    fi
    
    # set PYTHONPATH so it includes user's private Django directory if it exists
    if [ -d "$HOME/Django" ] ; then
        export PYTHONPATH="$HOME/Django:$PYTHONPATH"
    fi
    
    if [ $USER == myuser ]; then
        export WORKON_HOME=$HOME/.virtualenvs
        source /usr/local/bin/virtualenvwrapper.sh
    fi
    
  2. Esteban Feldman

    seems that

    os.path.expandvars(os.path.join('$VIRTUALENVWRAPPER_LOG_DIR', 'hook.log'))
    

    in line 72 of hook_loader.py is not expanding variables as it should... Python Bug?

  3. Alexey Kostyuk

    Seems virtualenvwrapper_run_hook () runs twice when you are activating your profile.

    At first time the line number 72 (os.path.expandvars(os.path.join('$VIRTUALENVWRAPPER_LOG_DIR', 'hook.log'))) is equal:

    $VIRTUALENVWRAPPER_LOG_DIR/hook.log (we have not yet $VIRTUALENVWRAPPER_LOG_DIR variable in the env)

    and for second time it is equal:

    /home/unit/.virtualenvs/hook.log

  4. Anonymous

    I am experiencing this problem as well on Ubuntu 11.04 with Python 2.7 and the latest versions of virtualenv and virtualenvwrapper. This seems to occur only when run by the login script... if I manually source virtualenvwrapper.sh it loads without this error.

  5. Anonymous

    In order to run virtualenvwrapper you can add the following to your .bashrc:

    export VIRTUALENVWRAPPER_LOG_DIR="$WORKON_HOME"
    export VIRTUALENVWRAPPER_HOOK_DIR="$WORKON_HOME"
    
  6. Doug Hellmann repo owner
    • changed status to open

    Is it correct to say that setting VIRTUALENVWRAPPER_LOG_DIR before sourcing virtualenvwrapper.sh eliminates the problem?

    Is anyone having this problem on a platform other than Ubuntu 11.04 using bash?

  7. Ian Lewis

    I'm having the problem on Debian 6.0 "squeeze" and setting the LOG_DIR and HOOK_DIR environment variables before sourcing the .sh doesn't fix the problem. I'm using python 2.7.1

    Actually, on my local Ubuntu PC, I don't have the problem and I'm using python 2.6.6 so it may be a python version related problem.

  8. Esteban Feldman

    Is not a python version problem. I'm using 2.7.1 on a fresh install of Ubuntu 11.04 I had this problem (other machine) on an upgrade from Ubuntu 10.10 -> 11.04 hence python 2.6 -> 2.7

  9. Anonymous

    I guess it is related to virtualenvwrapper package at least in ubuntu. I worked this out by removing /etc/bash_completion.d/virtualenvwrapper

    Now the only step required to activate virtualenvwrapper is to add: export WORKON_HOME=$HOME/.virtualenvs source /usr/local/bin/virtualenvwrapper.sh

    to .bashrc

    And there, no errors, everything works. I guess it is also possible to simply fix bash_completion.d/virtualenvwrapper file but I dont care for this file.

  10. Dries Desmet

    I had this same error on os x with virualenvwrapper 2.7.1 but it turned out I had forgotten to source the new virtualenvwrapper.sh file. At least on os x with python 2.6.1 this issue seems to be resolved.

  11. Anonymous

    Yes, I think the problem is caused with:

    apt-get remove virtualenvwapper

    followed by:

    easy_install virtualenvwrapper

    In particular, I believe that the apt-get remove fails to remove /etc/bash_completion.d/virtualenvwrapper , so that this gets run first, and generates the error.

  12. Jan Dittberner

    The /usr/local/bin/virtualenvwrapper.sh might conflict with the /etc/bash.completion.d/virtualenvwrapper from the Debian package. apt treats /etc/bash_completion.d/virtualenvwrapper as a configuration file and does not delete it if you don't use dpkg --purge or aptitude purge to uninstall the package.

    (I am the maintainer of the Debian package that eventually got integrated in Ubuntu by some Ubuntu people)

  13. Doug Hellmann repo owner

    Jan,

    What is in the bash completion file? Is it a shell script, or a simple list of candidate completions?

    Is the problem a matter of old vs. new versions? Would upgrading virtualenvwrapper through apt remove or update the file in a way that didn't produce the error message?

    Doug

  14. Jan Dittberner

    The bash completion file is just the virtualenvwrapper.sh copied to a place where Debian's bash completion magic gets it automatically. This Debian specific behaviour is documented in /usr/share/doc/virtualenvwrapper/README.Debian as follows:

    In contrast to the information in
    /usr/share/doc/virtualenvwrapper/en/html/index.html this package installs
    virtualenvwrapper.sh as /etc/bash_completion.d/virtualenvwrapper.
    
    Virtualenvwrapper is enabled if you install the package bash-completion and
    enable bash completion support in /etc/bash.bashrc or your ~/.bashrc.
    
    If you only want to use virtualenvwrapper you may just add
    
     source /etc/bash_completion.d/virtualenvwrapper
    
    to your ~/.bashrc.
    
  15. Anonymous

    I had same error on bash startup. Deleting /etc/bash_completion.d/virtualenvwrapper solves the problem, all we have to do is to add init commands for virtualenvwrapper to .bashrc or init it manualy each time we start shell.

  16. rwaters

    Issue 62 may also be related to this issue; it is the first resource that I found when experiencing this, and through testing I also came to the conclusion that the script /etc/bash_completion.d/virtualenvwrapper (ubuntu) was the culprit.

  17. Local Projects

    I realize that this is a long closed/resolved issue but I run into this every so often and wanted to document my path to fixing:

    Most times this seems to be due to a conflict in virtualenvwrapper scripts. So when this happens I've found it worthwhile to remove all versions of virtualenvwrapper, and re-install them. This is particularly true when the default python changes.

    So pip-2.X uninstall virtualenvwrapper for every X that you have. You may need to sudo this command. Then pip install virtualenvwrapper for the default python.

  18. Log in to comment