Python Virtual Environments Flashcards
Python virtual Environments
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 do we create a virtual environment with pipenv?
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 do we install packages with pipenv?
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.