在OSX上管理多个Python版本 [英] Managing multiple Python versions on OSX

查看:158
本文介绍了在OSX上管理多个Python版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我已经通过brew安装了Python 3,最好的方法是长期管理多个Python安装?过去,Python版本是在这里,那里和各处安装的,因为我使用不同的工具来安装各种更新.可以想象,这最终成为一个问题.

What's the best way to manage multiple Python installations (long-term) if I've already installed Python 3 via brew? In the past Python versions were installed here, there, and everywhere, because I used different tools to install various updates. As you can imagine, this eventually became a problem.

我曾经遇到一种情况,在我的一个项目中使用的软件包仅适用于Python 3.4,但是最近我更新到了3.6.我的代码不再运行,我不得不搜索Python 3.4的系统才能真正启动该项目.这是一个巨大的PITA.

I once was in a situation where a package used in one of my projects only worked with Python 3.4, but I had recently updated to 3.6. My code no longer ran, and I had to scour the system for Python 3.4 to actually fire up the project. It was a huge PITA.

我最近擦了擦我的电脑,并希望避免过去的一些错误.也许这很幼稚,但我想将版本安装限制为brew. (除非这是无意义的,否则我会接受其他建议!)此外,我想知道如何解决过去的版本管理问题(即上述情况).我听说过pyenv,但是会与brew冲突吗?

I recently wiped my computer and would like to avoid some of my past mistakes. Perhaps this is naïve, but I'd like to limit version installation to brew. (Unless that's non-sensical — I'm open to other suggestions!) Furthermore, I'd like to know how to resolve my past version management woes (i.e. situations like the one above). I've heard of pyenv, but would that conflict with brew?

谢谢!

推荐答案

使用virtualenvs可以减少独立项目之间的程序包冲突.激活venv后,使用pip安装软件包.这样,每个项目都可以独立查看包空间.

Use virtualenvs to reduce package clash between independent projects. After activating the venv use pip to install packages. This way each project has an independent view of the package space.

我使用brew安装Python 2.7和3.6.这些工具中的每一个的venv实用程序将分别构建2或3 venv.

I use brew to install both Python 2.7 and 3.6. The venv utility from each of these will build a 2 or 3 venv respectively.

我还从brew安装了pyenv,如果我想要的不是不是brew最新的特定版本,可以使用pyenv.在激活目录中的特定版本后,我将创建一个venv,并使用它来管理软件包隔离.

I also have pyenv installed from brew which I use if I want a specific version that is not the latest in brew. After activating a specific version in a directory, I will then create a venv and use this to manage the package isolation.

我真的不能说什么是最好的.让我们看看其他人怎么说.

I can't really say what is best. Let's see what other folks say.

这篇关于在OSX上管理多个Python版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆