Skip to content
Advertisement

Python equivalent of npm or rubygems?

I’ve been looking around for a package manager that can be used with python. I want to list project dependencies in a file.

For example ruby uses Gemfile where you can use bundle install.

How can I achieve this in Python?

Advertisement

Answer

The pip tool is becoming the standard in equivalent of Ruby’s gems.

Like distribute, pip uses the PyPI package repository (by default) for resolving and downloading dependencies.

pip can install dependencies from a file listing project dependencies (called requirements.txt by convention):

pip install -r requirements.txt

You can “freeze” the current packages on the Python path using pip as well:

pip freeze > requirements.txt

When used in combination with the virtualenv package, you can reliably create project Python environments with a project’s required dependencies.

Advertisement