当我也有 Python2.7 (OS X) 时,virtualenv 仅创建 /lib/Python2.6

发布于 2024-10-17 08:39:19 字数 679 浏览 9 评论 0原文

在我做任何其他事情之前,我在我的新 MacBook Pro(第一次使用 Mac 用户)上安装了 virtualenv(可能是个坏主意)。当我创建一个环境时,它内部包含 /lib/Python2.6 。后来我安装了Python2.7,但它仍然只在lib中包含一个Python2.6文件夹,所以我认为有些东西搞砸了。

注意:如果我进入终端并输入 python,我会正确获取 Python2.7。

我尝试通过以下方式重新安装 virtualenv:

pip install virtualenv --upgrade

并且

easy_install virtualenv

两者都有相同的结果。它们工作得很好,没有任何问题,但我在新环境的 lib 中仍然没有 Python2.7 文件夹(注意:每次升级为安全)...

顺便说一句,我也尝试过:

brew install virtualenv

但出现以下错误:

Error: No available formula for virtualenv

I installed virtualenv on my new MacBook Pro (first time Mac user) before I did anything else (probably a bad idea). When I create an env it contains /lib/Python2.6 inside of it. Afterward I installed Python2.7, but it still only includes a Python2.6 folder in lib, so I assume something is messed up.

Note: If I go to terminal and type python, I correctly get Python2.7.

I've tried to reinstall virtualenv via:

pip install virtualenv --upgrade

and, also

easy_install virtualenv

Both had the same result. They worked fine with no problems, but I still get no Python2.7 folder in lib on new envs (note: I closed and reopened the terminal each time I upgraded to be safe)...

On a side note, I also tried:

brew install virtualenv

but got the following error:

Error: No available formula for virtualenv

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

拥抱影子 2024-10-24 08:39:19
virtualenv foo_env --python=Python2.7

当您传递 python 参数时,它会为该版本设置 binlib(当然,假设您安装了该版本)。

virtualenv foo_env --python=Python2.7

When you pass the python argument, it sets up the bin and lib for that version (assuming you have that version installed, of course).

怎言笑 2024-10-24 08:39:19

这并不能回答你的问题,但我发现在 OS X 上启动和运行多个版本的 Python 的最简单方法是使用 macports。对于 PIP 和 VirtualEnv 等主要工具,macports 往往拥有最新版本,并且它可以很好地管理所有内容。

然后,您可以安装特定于每个已安装版本的 PIP,以及 virtualenv。对于不需要 virtualenv,但只需要针对不同版本进行测试的更一般情况,您也可以使用 macports 中的 python_select。

一旦你有了 macports 就可以通过

sudo port install python26 py26-pip py26-virtualenv python_select

编辑来安装它们:看来我对这个提倡使用 MacPorts 而不是 Homebrew 的回应感到不满。这个答案背后的原因是我被特别告知不要依赖 OS X 的 python 版本。这就是为什么我安装了冗余的 Macports Python 2.6,然后安装了所有工具来补充它。如果您觉得这个答案很差,请留下具体评论,说明原因以及如何改进。

This does not answer your question, but I have found the easiest way to get multiple versions of Python up and running on OS X is to use macports. For major tools like PIP and VirtualEnv, macports tends to have the latest versions and it manages everything fairly well.

Then you can install a PIP specific to each version installed, as well as virtualenv. For more general cases where you don't need virtualenv, but just need to test against different vesions, you can use python_select from macports as well.

Once you have macports can install them with

sudo port install python26 py26-pip py26-virtualenv python_select

EDIT: It seems I'm getting downvoted for this response for advocating the use of MacPorts over Homebrew. The reasoning behind this answer was that I was told specifically not to depend on the version of OS X's python. This is why I have a redundant Macports Python 2.6 install and then all of the tools to complement it. If you feel this answer is poor, please leave a specific comment as to why, and how to improve it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文