Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/280.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 终端启动时显示virtualenvwrapper.sh错误_Python_Linux - Fatal编程技术网

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

Python 终端启动时显示virtualenvwrapper.sh错误,python,linux,Python,Linux,在开始学习Python编程时,我通过以下命令安装了VirtualEnvrapper: # 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_ins

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

# 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

请帮助:(

您需要设置
VIRTUALENVWRAPPER\u LOG\u DIR
环境变量。将此变量添加到
.bashrc
文件中:

VIRTUALENVWRAPPER_LOG_DIR=/tmp
export VIRTUALENVWRAPPER_LOG_DIR

在Debian上运行时,我遇到了类似的问题。我需要以X用户以外的用户身份运行它,但它使用了X用户的
~/.virtualenvs
目录,用于
WORKON\u HOME
VIRTUALENVWRAPPER\u LOG\u DIR
VIRTUALENVWRAPPER\u HOOK\u DIR


现在,我将这些变量设置到
~/.bashrc

中的一个适当目录中,对于后来的人,我在Ubuntu 12上遇到了同样的问题,并通过这种方式解决了:

  • 切换到正确的用户:

    su username
    
  • 确保您的WORKON_HOME变量设置为您想要的路径(默认为~/.virtualenv)

  • 然后在源命令之前添加以下两行:

    export VIRTUALENVWRAPPER_LOG_DIR="$WORKON_HOME"
    export VIRTUALENVWRAPPER_HOOK_DIR="$WORKON_HOME"
    
  • 然后保存并重新配置bashrc:

    source ~/.bashrc
    
  • ,这似乎是Debian/Ubuntu/Mint上的APT软件包的一个错误

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

    apt-get install virtualenvwrapper
    apt-get remove virtualenvwrapper
    pip install virtualenvwrapper
    
    APT软件包已添加文件
    /etc/bash_completion.d/virtualenvwrapper
    ,但未将其删除。这是导致问题的文件


    建议的解决方案是删除此文件,错误不再出现。(奇怪的是,仅仅重命名文件是不够的。)

    要在debian remove下完全删除,请执行以下操作:

    /usr/local/bin/virtualenvwrapper*
    /etc/bash_completion.d/virtualenvwrapper
    
    这对我很有用


    还可以从python的dist包中删除文件(取决于发行版和python版本)

    尝试使用如下导出命令:

    $export VIRTUALENVWRAPPER_LOG_DIR = "/path/to/the/hook.log"
    
    在我的例子中,hook.log的创建路径与我的virtualenvwrapper配置在/home/my_user/.virtualenvs中的路径相同,所以我所做的就是像这样导出变量

    $export VIRTUALENVWRAPPER_LOG_DIR = "./"
    

    我也有类似的问题。我删除了~/.bashrc中与virtualenv相关的所有设置,例如:

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

    这修复了错误。

    Hi.感谢John Keyes的回复,但仍然显示相同的错误。用.bashrc上的文章编辑了第一篇文章。希望我们能尽快解决这个问题:(再次感谢。它可以工作,但不能解决问题。您不应该手动定义这些变量。工作但不能解决是什么意思?手动是什么意思?--如果您将变量放在bashrc文件中,它应该始终工作。我的意思是,没有理由在virtualenvwrapper.sh之外定义这些变量除非你有很好的理由“它解决了一个奇怪的问题”理由不充分。您的解决方案解决问题的效果不如修补解决方法。这会给您的系统带来不必要的复杂性,这些复杂性会迅速堆积起来,导致无法维护。这类似于访问和修改API的私有变量,并调用已解决的问题。我理解您的观点;这是真的不幸的是,除了修补它,我不知道足够的理论。老实说,网络上似乎没有其他人知道——我已经看过了。自从我在Mac上工作以来,我在我的.profile中做了大量的评论,以使这堆东西更整洁。不过,你是对的,我欢迎另一种解决方案。我当时的情况非常相似,而且写下我在下面的答案中发现的内容。如果你想更好地理解这个问题,请阅读我链接的bug报告中的评论。这正是我所做的;我使用apt get for virtualenvwrapper,却发现它比我希望的要旧。在使用pip安装virtualenvwrapper时,我收到了openingpost中的错误。为了帮助我们e virtualenvwrapper在删除您建议的文件后,我仍然需要执行
    source/usr/local/bin/virtualenvwrapper.sh
    ,然后才能使用它。使用pip安装的解决方案对我很有效。我使用的是Debian,当时正在使用适用于virtualenvwrapper的APT软件包。
    $export VIRTUALENVWRAPPER_LOG_DIR = "/path/to/the/hook.log"
    
    $export VIRTUALENVWRAPPER_LOG_DIR = "./"
    
     # virtualenv
     #export WORKON_HOME=~/virtualenvs
     #source /usr/local/bin/virtualenvwrapper.sh