TAGS

There are no tags associated with this article.

How to install pipenv and pipenv-pipes?

In python programming, virtual environments play a significant role. They allow you to separate packages into different spaces. This kind of treatment does not collide with globally installed packages, hence you can experiment with dozen of particular versions and package-dependencies.

 

Pipenv

It is a tool that automatically creates a virtualenv on your desire. It is also capable of adding/removing packages from your configuration files.

 

Pipenv-Pipes

It is tool that is being used for switching between environments.

 

Installation

(As a example Ubuntu 18.04)

1. Open your terminal.

2. Install pipenv and pipenv-pipes using pip3 command.

eouser@CREODIAS:~$ pip3 install pipenv pipenv-pipes --user

--user flag inform pip to locate the package installation into your home directory

Edit your profile in order to run pipenv from anywhere.

eouser@CREODIAS:~$ nano ~/.profile

add one line at the end of the document

export PATH="$PATH:/home/CREODIAS/.local/bin"
Change CREODIAS to your username.

Next, run source .profile by entering:

eouser@CREODIAS:~$ source~/.profile
Create an virtual environment Make a directory and cd into it:
eouser@CREODIAS:~$ mkdirenvironment_for_python_2

eouser@CREODIAS:~$ cdenvironment_for_python_2

Run this command in order to create a virtual environment, install flask and its dependencies.

eouser@CREODIAS:~/environment_for_python_2$ pipenv installflask --two

--two flag choose the python interpreter in version 2.

After installation you can activate virtual environment by using pipenv shell command.

(environment_for_python_2) eouser@test1:~/environment_for_python_2$.
On the left of your username you can findout about current environment activated

You can exit current environment by typing in exit.

Pipfile

When you examine a Pipfile which is automatically generated during environment creation, you can find four different tabs source, dev-packages, packages and requires.

[[source]]
name = "pypi"
url = "https://pypi.org/simple"

verify_ssl = true


[dev-packages]


[packages]

flask = "*"


[requires]

python_version = "2.7"

Explanation

Source → Define a Python repository location

dev-packages → experimental packages installed in virtual environment

packages → normal packages that has been demanded to be installed

requires → restrictions concerning packages and python versions

Pipfile.lock

In Pipfile.lock you can check checksum such as sha256 or md5 for particular packages.

It is not intended to be edited by user!

Help

To list all available commands you can just type in pipenv.

Pipes usage

If you create more than virtual environment, you can switch between them using pipes command (Its output generates an interactive list with all available environments)

Pipenv Environments
environment_for_python_2-XLko4iGZ
environment_for_python_3-Awp387mO