The Python Package Dreamteam

Previously with venv, I wrote a Makefile that would write the specific versions to a requirements_versions.


This wasn’t ideal, since it wouldn’t record the specific Python version, and sometimes you’d forget to run the Make commands.

Based on my workflow and previous experiences with venv, I had some key requirements:1.

Seamlessly record specific Python/package versions.


Play nicely with multiple Python versions.


Keep stuff within the project directory as much as possible.

pyenvpyenv is a super nice tool for managing multiple Python versions alongside each other.

You can easily set your global Python version, launch a shell using a specific version, or set a version for a specific project.

On MacOS, installation was relatively straightforward:1.

xcode-select — install2.

brew install openssl readline sqlite3 xz zlib3.

brew update4.

brew install pyenv5.

Add eval “$(pyenv init -)” to your shell configuration file.


exec “$SHELL”Now you can easily install and use different Python versions with pyenv’s simple commands.

These include pyenv install to install a specific version, pyenv global to set to set the global version, and pyenv local to set a directory-specific version.

You can also use an environment variable, PYENV_VERSION, to set the version for a specific session.

pipenvpipenv is, in my opinion, the best package manager for python.

It automatically creates and manages virtual environments for your projects as you go.

It also works with pyenv to install and use python versions as required, which is life changing.

On MacOS, installation is as easy as:1.

brew install pipenvBecause it’s installed independently, you also won’t get any of those weird,You are using pip version 9.


1, however version 18.

0 is available.

that never seem to go away.

pipenv works with a Pipfile instead of a requirements.


When you first run pipenv install (which you can use just like pip install) in a project directory, it will create a Pipfile in that directory.

You can even install from a requirements.

txt using pipenv install -r requirements.


This file will automatically update when you install, remove, or update packages.

It also records your python version!.Activating the environment is as simple as running pipenv shell from that project’s directory.

No more trying to remember where you put your environment or what you called it!ConclusionIt’s super easy to ignore proper package version management, especially as a Data Scientist.

However, the problems improper version management cause can really add up.

From not being able to have collaborators run your code, to not being able to run your own code a few months down the line, you can easily waste a lot of time fixing dependency issues.

It can also be a frustrating thing to get right.

For me, the pipenv/pyenv combo has been a treat to work with.

It automates the right amount of stuff, without sacrificing consistency.

.. More details

Leave a Reply