Python Virtual Environments Flashcards

1
Q

Python virtual Environments

A

Python virtual environments allows you to manage the dependencies for a project in separate environments. Packages are installed at the project level not globally. pipenv is one package used to create and manage these environments.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How do we create a virtual environment with pipenv?

A

Make sure the pipenv module is installed. navigate to the root of the project directory and execute the command:
$ pipenv –three
this will initialize the virtual enviroment.
Note a ‘pipfile’ will be created in the directory that contains all the info about the virtual environment and the project dependencies.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do we install packages with pipenv?

A

Make sure your in the desired project directory, use the command:
$ pipenv install package_name

to specify a version of a package use:
$ pipenv install package_name ==2.18.1

Note that using the command:
$ pipenv shell
will allow you use the shell within that virtual environment with all it’s specific dependencies.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly