kylemart
kylemart

Reputation: 1276

Managing multiple Python versions on OSX

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.

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.

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?

Thanks!

Upvotes: 0

Views: 610

Answers (2)

Aswini
Aswini

Reputation: 46

I agree to using virtualenv, it allows you to manage different python versions separately for different projects and clients. This basically allows you to have each project it's own dependencies which are isolated from others.

Upvotes: 0

mjr104
mjr104

Reputation: 193

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.

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.

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.

Upvotes: 2

Related Questions