virtualenvwrapper.user_scripts 找不到 get_env_details

virtualenvwrapper.user_scripts could not find get_env_details

当我运行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执行Migration Assistant后出现的

我正在使用 Python 2 与 Homebrew 一起安装。 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 "3]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}[=14=]7"'
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  ) )
# }
# 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

当我遇到这样的事情时,我通常会重新安装 Homebrew。在 SO 上看到这个 link:Safest way to reinstall Homebrew

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

现在给出实际答案有点晚了,但我希望它能帮助将来遇到同样问题的人。

实际发生了什么:

  • 我全新安装了 OS。

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

解决方案是使用 macOS Recovery 并选择 "Restore from Time Machine"。