pip? Virtualenv? pyenv? Which is which?

· 4 min

I was looking for a package management tool and a runtime version management tool in Python which has the same role as npm or yarn and nodebrew in the node.js environment.

But in Python, there are so many, or more like too many, same kinds of tools, and top of that, they sound very similar. Which one should I use for my project?

I’m new to Python, therefore there are several misunderstands for sure. Any comments and corrections are welcome.


  • Use Pyenv to manage the multiple version of Python.
  • Use Pipenv to manage package dependencies for your projects.
  • It’s better to know how to use pip and Virtualenv since Pipenv is new thus, there are a lot of projects using pip and Virtualenv exist.

pip a basic package management tool

pip was an officially recommended package management tool. It does (almost) same tasks as npm does. You can install packages from PyPI. An important point is that pip installs all packages to global place in default as opposed to local directory installation which npm does.

Note: pip is also PyPI package. You can find it here

what about easy_install?

easy_install is also a package management tool which used to be the standard tool of package managemnt in Python. But It’s replaced by pip.

There are a comparison table and detailed information about the differences between easy_install and pip here.

Virtualenv separates environments

Since pip installs all packages in global, there is a big problem. If you are working for more than two projects on the same computer, and if the projects depending on the same package but a different version. it’s going to conflict. To solve that problem, Virtualenv was made.

With Virtualenv, we can install the packages for each project locally like npm’s node_modules directory.

Pipenv the BEST way to manage packages

Pipenv is also a package management tool (hey, how many tools you guys have) but it installs packages locally in default, wow! You can think Pipenv is the Python version of npm.

Pipenv is a new tool if compare to others since the first version was released in Jan 20, 2017. However, it’s recommended by Python officail.

Use Pipenv to manage library dependencies when developing Python applications. Tool recommendations — Python Packaging User Guide

There is an article written by the author of Pipenv about the problem of pip workflow. You should check this article and chose Pipenv as a package manager for your projects if possible.

Pyenv Python version management tool

With Pyenv, you can switch the versions of Python on your computer. It has the same role as nodebrew has.

pyenv-virutalenv is needed

You need to install pyenv-virtualenv to use Virtualenv with Pyenv because Virutalenv relies on $PATH that will be modified by Pyenv. (the details are here)

Pipenv, the BEST package manager, so far, handles Pyenv environment for you by default.

If you have pyenv installed and configured, Pipenv will automatically ask you if you want to install a required version of Python if you don’t already have it available. Advanced Usage of Pipenv — pipenv 2018.10.14.dev0 documentation

Failed to install Python 3.6.6 on Mac High Sierra

There was a problem when I tried to install Python 3.6.6 on my Mac.

zipimport.ZipImportError: can't decompress data; zlib not available

If you have the same problem, you can solve that by passing those compile options shown below.

env CFLAGS="-I"(brew --prefix openssl)"/include -I"(xcrun --show-sdk-path)"/usr/include" \
env LDFLAGS="-L"(brew --prefix openssl)"/lib" \
pyenv install -v 3.6.6

Thanks Can’t compile any versions of python on El Capitan · Issue #451 · pyenv/pyenv · GitHub

Next step, direnv

I found something seems very useful called direnv - unclutter your .profile. We can control environment variables depending on the current working directory. I’ll check this later, I might.

Thank you for reading, see ya again ;)


Shota Senga


Software Developer who enjoys beer 🍻 and music 🎧