Python equivalent of npm or rubygems

Pipenv

(I know it's an old question, and it already has an answer but for anyone coming here looking for a different answer like me.)

I've found a very good equivalent for npm, It's called pipenv. It handles both virtualenv and pip requirements at the same time so it's more like npm.


Simple Use Case

pip install pipenv

then you can make a new virtualenv with third version of python, as well as making a pipfile that will be filled with your projects requirement and other stuff:

pipenv install --three

using your created virtualenv:

pipenv shell

installing a new python package:

pipenv install requests

running your .py file is like:

pipenv run python somefile.py

you can find it's doc here.


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.


Python uses pip for a package manager. The pip install command has a -r <file> option to install packages from the specified requirements file.

Install command:

pip install -r requirements.txt

Example requirements.txt contents:

Foo >= 1.2
PickyThing <1.6,>1.9,!=1.9.6,<2.0a0,==2.4c1
SomethingWhoseVersionIDontCareAbout

See the Requirements Parsing section of the docs for a full description of the format: https://pip.pypa.io/en/stable/user_guide/#requirements-files