Managing Multiple Python Versions and Packages

After spending a solid afternoon researching and working on deploying multiple Python versions and packages, I realized how much confusion and lack of authoritative posts exist on this subject. There are lots of opinions and suggestions out there which may not be correct at all or more often the case, half correct. It’s a pretty tricky subject with a myriad of potential pitfalls. In this short post, I hope to provide some guidance from my own learnings.

What complicates this subject even more is there are numerous package managers and methods of trying to achieve the same goal. Unfortunately, many folks who are just looking to get started developing may not really understand the impact of using a certain package manager or method to deploy Python and respective packages. Another complication is that things may work smoothly at first, until an update occurs or another Python/package version needs deployed for some specific scenario (Ex: development where certain python/package version is required for things to work); at this point things start to fall apart.

I am a heavy Mac and Linux user; in this case, I was using a Mac. For what I needed to accomplish, I’ve been able to achieve:

  • a development environment where I have multiple Python versions and respective packages running
  • can easily switch between Python versions and respective packages when working on different projects
  • can easily install Python packages for a specific Python version
  • can isolate Python packages to a specific project
  • removed dependencies on default system Python components
  • avoid issues that can occur when using Homebrew

I hope to write a follow-up with more details, but to help others save time and avoid hours of banging their head off the desk, the following is what I used. Note, I use Pyenv to manage Python versions and Pipenv in conjunction to manage respective Python packages. I only use Homebrew to install Pyenv which is not tied to any specific Pyhton version. Most importantly, I have no dependency on the default Mac Python version or any Homebrew Python versions.

  • Install Pyenv (Ex: brew install pyenv)
  • Using Pyenv – Install Python versions you would like to use and set one as Global; this will be your default (Ex: pyenv global 3.9.10)
  • Install Pipenv (Ex: pip install –user pipenv)

Above will give you benefits I mentioned prior; however, you still need to understand how to use these tools and should read up on the specifics. Watch-out for a follow-up post!

Follow me on Twitter: @Humair_Ahmed

This entry was posted in Development Tools, Mac, Mac OS X Big Sur, Mac OS X Catalina, Mac OS X Mavericks, Mac OS X Mojave, Mac OS X Monterey, Mac OS X Yosemite, Operating Systems, Python, Technology, Tips & Tricks and tagged , , , , , , , , , , , , , , . Bookmark the permalink.

4 Responses to Managing Multiple Python Versions and Packages

  1. Sony Blade says:

    I am having a trouble finding follow-up post on this

  2. Pingback: Managing Multiple Python Installs and Packages with Pyenv and Pipenv | HumairAhmed.com

  3. Humair says:

    Hadn’t had time to get around to it earlier, but just posted here:

    Managing Multiple Python Installs and Packages with Pyenv and Pipenv
    https://humairahmed.com/blog/?p=10648

  4. Pingback: asdf for Managing Multiple Tool Runtime Versions | HumairAhmed.com

Leave a Reply

Your email address will not be published. Required fields are marked *


− 1 = four