Python Package management tool pipenv

Source: Internet
Author: User
Tags virtual environment

Kenneth Reitz's newest tool pipenv can be used to simplify the management of dependencies in Python projects. It brings together the features of Pip,pipfile and Virtualenv and is a powerful command-line tool.

Entry

First use PIP to install pipenv and its dependencies,

Pip Install Pipenv

Then change the directory to the folder that contains your Python project and start Pipenv,

CD my_projectpipenv Install

This will create two new files in the project directory Pipfile and Pipfile.lock, and if the project does not exist, create a new virtual environment for the project. If you add the –two or –three flag to the last command above, it initializes your project using Python 2 or three, respectively. Otherwise, the default version of Python will be used.

Managing Python Dependencies

Pipfile contains information about the dependencies of the project and supersedes the Requirements.txt files that are commonly used in Python projects. If you started pipenv in a project that has a requirements.txt file, you should use Pipenv to install all the dependent packages listed in the file before you remove it from the project.

To install a Python package for your project, use the Install key

Word. For example

Pipenv Install BEAUTIFULSOUP4

The current version of the beautiful soup package will be installed. You can use the Uninstall keyword to delete a package in a similar way,

Pipenv Uninstall BEAUTIFULSOUP4

You can freeze the package name and its version, as well as a list of its dependencies, by updating Pipfile.lock. This can be done using the Lock keyword,

Pipenv Lock

If another user clones the repository, you can add pipfiles to your git repository so they only need to install pipenv on their system, and then type,

Pipenv Install

Pipenv will automatically find the Pipfiles, create a new virtual environment and install the necessary packages.

Manage your development environment

Typically, there are python packages that are only needed in your development environment, not in your production environment, such as unit test packages. Pipenv will use the –DEV flag to keep the two environments separate

Pipenv Install--dev Nose2

Nose2, but it is also associated with packages that are only needed in the development environment. This is useful because now if you want to install your project in your production environment,

Pipenv Install

The NOSE2 package is not installed by default. However, if another developer clones your project into their own development environment, they can use the –DEV flag,

Pipenv Install–dev

and install all dependencies, including development packages.

Python Package management tool pipenv

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.