gpt4 book ai didi

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

转载 作者:IT王子 更新时间:2023-10-29 00:23:44 25 4
gpt4 key购买 nike

当我开始学习 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

我每次打开终端(通过 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.

我使用的是 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

请帮忙:(

最佳答案

According to this ,似乎是Debian/Ubuntu/Mint上的APT包出错。

我先通过APT安装了virtualenvwrapper,然后删除它并通过pip安装。

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

APT 包添加了文件 /etc/bash_completion.d/virtualenvwrapper 但没有删除它。这是导致问题的文件。

推荐的解决方案是删除此文件,这样错误就不会再出现了。 (奇怪的是,仅仅重命名文件是不够的)。

关于python - 终端启动时显示 virtualenvwrapper.sh 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7658075/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com