如何在 mac 上运行 virtualenv python [英] how to run virtualenv python on mac
问题描述
我正在尝试使用 virtualenv 在我的 mac 上创建一个虚拟的 python 环境.我已经下载了 virtualenv,但是我无法运行它,因为即使我提供了正确的路径,它也找不到我安装 python3 的路径.这是我运行的命令和响应:
I am trying to use virtualenv to create a virtual python environment on my mac. I have downloaded virtualenv however I can't run it because it can't find the path to my installation of python3 even though I am supplying the correct path. Here is the command I have run and the response:
virtualenv --python=/usr/local/bin/python3 newfolder
zsh: /usr/local/bin/virtualenv: bad interpreter: /usr/local/opt/python3/bin/python3.6: no such file or directory
我也试过用这样的引号运行命令:
Also I have tried running the command with quotes like so:
virtualenv --python='/usr/local/bin/python3' newfolder
zsh: /usr/local/bin/virtualenv: bad interpreter: /usr/local/opt/python3/bin/python3.6: no such file or directory
请注意,据我所知,我提供了正确的 python3 路径.
这是我运行 which python3
Please note I am supplying the correct path to python3 as far as I can tell.
Here is what I get when I run which python3
which python3
/usr/local/bin/python3
virtualenv 似乎也已正确安装.以下是这方面的证据:
Also virtualenv appears to be correctly installed. Here is evidence for this:
pip3 install virtualenv
Requirement already satisfied: virtualenv in /Users/mathewlewis/Library/Python/3.7/lib/python/site-packages (16.7.9)
另外,如果这是相关的,我目前拥有的软件是 mac os catalina 10.15.2
Also, in case this is relevant, the software I have is currently mac os catalina 10.15.2
我不仅想要一个解决方案(正如此时给出的那样),我还想要一个为什么这不起作用的原因.
Not only would I like a solution (as has been given at this point) I would also like a reason why this didn't work.
推荐答案
尝试:
python3 -m venv venv
source ./venv/bin/activate
这篇关于如何在 mac 上运行 virtualenv python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!