python pip and pipenv


Author: yifei / Created: May 30, 2017, 11:04 a.m. / Modified: May 30, 2017, 11:08 a.m. / Edit

pip is python's package manage tool.

installing packages

to install a package from PyPI:

pip install <package-name>==<version>, version is optional

To install a package from git repository:

pip install -e git+REPO

pip currently supports cloning over git, git+https and git+ssh:

Here are the supported forms:

[-e] git+git://git.myproject.org/MyProject#egg=MyProject
[-e] git+https://git.myproject.org/MyProject#egg=MyProject
[-e] git+ssh://git.myproject.org/MyProject#egg=MyProject  # for private repo, you can only use this
[-e] git+git@git.myproject.org:MyProject#egg=MyProject

Passing branch names, a commit hash or a tag name is possible like so:
[-e] git://git.myproject.org/MyProject.git@master#egg=MyProject
[-e] git://git.myproject.org/MyProject.git@v1.0#egg=MyProject
[-e] git://git.myproject.org/MyProject.git@da39a3ee5e6b4b0d3255bfef95601890afd80709#egg=MyProject

if you add the -e(editable) option, then you can save the version info in freeze, which is exactly what you need.

upgrade a package:

pip install package-name --upgrade

requirements file

save current dependencies to a requirement file:

pip freeze > requirements.txt

install from a requirement file

pip install -r requirements.txt

pipenv seems to be the best tool for now, read it here: http://crazygit.wiseturtles.com/2018/01/08/pipenv-tour/


评论区