virtualenvwrapper.sh错误显示在终端启动时

koh*_*ime 15 python linux

当我开始学习Python编程时,我通过以下命令安装了virtualenvwrapper:

# 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
Run Code Online (Sandbox Code Playgroud)

我每次打开终端时都会收到此错误(通过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.
Run Code Online (Sandbox Code Playgroud)

我正在使用Linux Mint 10 64位GNOME.

有没有办法解决我在终端中看到的这个错误?

我试过通过谷歌搜索,但似乎没有一个解决这个问题.

先感谢您.

===编辑===

这是在/home/user/.bashrc中编写的内容

source /usr/local/bin/virtualenvwrapper.sh 2> /dev/null
VIRTUALENVWRAPPER_LOG_DIR=/tmp
export VIRTUALENVWRAPPER_LOG_DIR
Run Code Online (Sandbox Code Playgroud)

请帮忙 :(

rah*_*hmu 16

根据这一点,Debian/Ubuntu/Mint上的APT包似乎是错误的.

我先通过APT安装了virtualenvwrapper,然后将其删除并通过pip安装.

apt-get install virtualenvwrapper
apt-get remove virtualenvwrapper
pip install virtualenvwrapper
Run Code Online (Sandbox Code Playgroud)

APT包已添加该文件/etc/bash_completion.d/virtualenvwrapper但未删除它.这是导致问题的文件.

建议的解决方案是删除此文件,并且错误停止显示.(奇怪的是,简单地重命名文件是不够的).


x -*_*- y 6

对于那些之后来的人,我在Ubuntu 12上遇到了同样的问题并且解决了这个问题:

  1. 切换到正确的用户:

    su username
    
    Run Code Online (Sandbox Code Playgroud)
  2. 确保你的WORKON_HOME变量设置为你想要的路径(默认为〜/ .virtualenv)

    WORKON_HOME=$HOME/.virtualenv
    
    Run Code Online (Sandbox Code Playgroud)
  3. 然后在源命令之前添加这两行:

    export VIRTUALENVWRAPPER_LOG_DIR="$WORKON_HOME"
    export VIRTUALENVWRAPPER_HOOK_DIR="$WORKON_HOME"
    
    Run Code Online (Sandbox Code Playgroud)
  4. 然后保存并重新获取bashrc:

    source ~/.bashrc
    
    Run Code Online (Sandbox Code Playgroud)


Joh*_*yes 0

您需要设置环境VIRTUALENVWRAPPER_LOG_DIR变量。将其添加到您的.bashrc文件中:

VIRTUALENVWRAPPER_LOG_DIR=/tmp
export VIRTUALENVWRAPPER_LOG_DIR
Run Code Online (Sandbox Code Playgroud)