virtualenvwrapper.user_scripts找不到get_env_details

时间:2015-07-22 19:39:38

标签: python virtualenv osx-mavericks homebrew virtualenvwrapper

当我运行mkvirtualenv TESTING时:

New python executable in TESTING/bin/python2.7
Also creating executable in TESTING/bin/python
Installing setuptools, pip, wheel...done.
virtualenvwrapper.user_scripts could not run "/Users/admin/.virtualenvs/TESTING/bin/preactivate": [Errno 2] No such file or directory

运行lsvirtualenv时出现类似错误:

bpython-dev
===========
virtualenvwrapper.user_scripts could not run
"/Users/admin/.virtualenvs/bpython-dev/bin/get_env_details": [Errno 2] No such file or directory

我已经检查了.virtualenvs / bpython-dev /(以及其他虚拟环境)以查看是否存在get_env_details,它是。

我在Mavericks上使用Time Machine执行迁移助手后发生此问题。

我正在使用Homebrew安装的Python 2。 which python会产生usr/local/bin/pythonwhich pip会产生usr/local/bin/pip

我的.bash_profile

# Load /usr/local/ before /usr/bin/
export PATH=/usr/local/bin:$PATH
export PATH=$HOME/bin:$PATH


# Load the default .profile
[[ -s "$HOME/.profile" ]] && source "$HOME/.profile"


# Virtualenvwrapper
export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/Hacker\ School/
export PIP_VIRTUALENV_BASE=$WORKON_HOME
export PIP_RESPECT_VIRTUALENV=true
source /usr/local/bin/virtualenvwrapper.sh 


# Timing terminal directory tracking
PROMPT_TITLE='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}\007"'
export PROMPT_COMMAND="${PROMPT_COMMAND} ${PROMPT_TITLE}; "

export DJANGO_COLORS="dark"


# _django_completion()
# {
#     COMPREPLY=( $( COMP_WORDS="${COMP_WORDS[*]}" \
#                    COMP_CWORD=$COMP_CWORD \
#                    DJANGO_AUTO_COMPLETE=1 $1 ) )
# }
# complete -F _django_completion -o default django-admin.py manage.py django-admin

# _python_django_completion()
# {
#     if [[ ${COMP_CWORD} -ge 2 ]]; then
#         PYTHON_EXE=${COMP_WORDS[0]##*/}
#         echo $PYTHON_EXE | egrep "python([2-9]\.[0-9])?" >/dev/null 2>&1
#         if [[ $? == 0 ]]; then
#             PYTHON_SCRIPT=${COMP_WORDS[1]##*/}
#             echo $PYTHON_SCRIPT | egrep "manage\.py|django-admin(\.py)?" >/dev/null 2>&1
#             if [[ $? == 0 ]]; then
#                 COMPREPLY=( $( COMP_WORDS="${COMP_WORDS[*]:1}" \
#                                COMP_CWORD=$(( COMP_CWORD-1 )) \
#                                DJANGO_AUTO_COMPLETE=1 ${COMP_WORDS[*]} ) )
#             fi
#         fi
#     fi
# }

# # Support for multiple interpreters.
# unset pythons
# if command -v whereis &>/dev/null; then
#     python_interpreters=$(whereis python | cut -d " " -f 2-)
#     for python in $python_interpreters; do
#         pythons="${pythons} ${python##*/}"
#     done
#     pythons=$(echo $pythons | tr " " "\n" | sort -u | tr "\n" " ")
# else
#     pythons=python
# fi

# complete -F _python_django_completion -o default $pythons
# Setting PATH for Python 2.7
# The orginal version is saved in .bash_profile.pysave
PATH="usr/local/Cellar/python/2.7.10_2/bin/:${PATH}"
export PATH

# Homebrew, OpenCV
export PATH="/usr/local/Cellar/opencv/2.4.9/lib/python2.7:$PATH"
export PYTHONPATH=/usr/local/lib/python2.7/site-packages:$PYTHONPATH

2 个答案:

答案 0 :(得分:1)

当我发生这样的事情时,我通常会重新安装Homebrew。请参阅SO上的此链接:Safest way to reinstall Homebrew

之后,您可能需要重新创建Python Virtualenv(以获取正确的Python二进制文件和库)。

答案 1 :(得分:0)

实际答案有点晚了,但我希望它可以帮助将来遇到同样问题的人。

实际发生了什么:

  • 我重新安装了操作系统。

  • 我使用Migration Assistant从Time Machine迁移数据。我相信这一步破坏了我的环境和路径。

解决方案是使用macOS Recovery并选择“从Time Machine恢复”。

相关问题