如果我尝试创建一个虚拟环境,我得到这个错误消息,我不明白:错误的解释程序:没有这样的文件或目录。我已经查看了this stack overflow answer,并尝试在下面的诊断步骤中应用它。
这是我第一天在莫哈韦跑步,但我不知道这是否是这个问题的一个因素。
我已在/Users/Wes/Dropbox/Programming/Python/glade_againn
为项目创建了一个新的空文件夹
我的计划是在virtualenv /Users/Wes/.virtualenvs/glade_againn
中运行该项目
但是,当我尝试使用virtualenv时,我收到了此错误消息。
$ virtualenv --version
-bash: /usr/local/bin/virtualenv: /usr/local/opt/python/bin/python2.7: bad interpreter: No such file or directory
如果我尝试用PIP安装virtualenv,我被告知它已经存在。
$ pip install virtualenv
Requirement already satisfied: virtualenv in /usr/local/lib/python2.7/site-packages (15.2.0)
$
我当前的路径是
echo $PATH
/Library/Frameworks/Python.framework/Versions/3.6/bin:/opt/local/bin:/opt/local/sbin:/usr/local/opt/postgresql@9.4/bin:/usr/local/Cellar/postgresql/9.5.4_1/bin/psql/:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Applications/Wireshark.app/Contents/MacOS:/usr/local/git/bin:/Users/Wes/bin:/sw/bin:/usr/local/bin:/Users/Wes/.sdkman/candidates/groovy/current/bin/
如果您在所有这些目录中搜索python *,您会得到这个列表,顺序如下。
/Library/Frameworks/Python.framework/Versions/3.6/bin/python3
/Library/Frameworks/Python.framework/Versions/3.6/bin/python3-config
/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6
/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6-config
/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6m
/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6m-config
/opt/local/bin/python2.7
/opt/local/bin/python2.7-config
/opt/local/bin/python3.4
/opt/local/bin/python3.4-config
/opt/local/bin/python3.4m
/opt/local/bin/python3.4m-config
/opt/local/bin/pythonw2.7
/usr/local/bin/python-32
/usr/local/bin/python2-32
/usr/local/bin/python2.7-32
/usr/local/bin/python3
/usr/local/bin/python3-config
/usr/local/bin/python3.6
/usr/local/bin/python3.6-config
/usr/local/bin/python3.6m
/usr/local/bin/python3.6m-config
/usr/local/bin/pythoni
/usr/local/bin/pythoni1
/usr/local/bin/pythonw-32
/usr/local/bin/pythonw2-32
/usr/local/bin/pythonw2.7-32
/usr/bin/python
/usr/bin/python-config
/usr/bin/python2.7
/usr/bin/python2.7-config
/usr/bin/pythonw
/usr/bin/pythonw2.7
/sw/bin/python2.7
/sw/bin/python2.7-config
/usr/local/bin/python-32
/usr/local/bin/python2-32
/usr/local/bin/python2.7-32
/usr/local/bin/python3
/usr/local/bin/python3-config
/usr/local/bin/python3.6
/usr/local/bin/python3.6-config
/usr/local/bin/python3.6m
/usr/local/bin/python3.6m-config
/usr/local/bin/pythoni
/usr/local/bin/pythoni1
/usr/local/bin/pythonw-32
/usr/local/bin/pythonw2-32
/usr/local/bin/pythonw2.7-32
有人对如何让virtualenv重新工作有什么建议吗?
5条答案
按热度按时间qjp7pelc1#
尝试使用此重新安装
如果以上解决方案不适合您,您应该因为莫哈韦更新而再次创建一个新virtualenv
kr98yfug2#
在我的例子中,我正在重命名项目和
venv
所在的项目文件夹。因此,在我的例子中,我在以下文件中更改了python解释器的路径:
并将
~/PycharmProjects/myproject/venv/bin/pip*
文件修改为:要修改它,我需要以root权限登录:
sudo su
。sudo vim.tiny venv/bin/pip
只是不允许我编辑文件。我只更改了以
#!/home...
开头的第一行6bc51xsx3#
在我的例子中,我在MacOS上安装了python3.9,但virtualenv是使用python3.7安装的,在某个时候我卸载了python3.7。
不过,我的python版本:
再多的pip或pip 3安装/卸载/安装virtualenv对我都不起作用,最后我做了以下操作:
然后
耶!
eni9jsuy4#
这就解决了我的问题:(我的env文件名为
.venv)
332nm8kg5#
在我的例子中,错误显示在Github操作中,根本原因是损坏的python符号链接。作为一种解决方案,我只是在过程中简单地重新创建它。