Here's a list of commands for using pipenv, which is mostly coming from this website:
pip install --user pipenv
Create a new virtual environment:
pipenv --python 3.6 # Any *installed* python version works
Removing said virtual environment:
pipenv --rm
You can install the dependencies if there is an existing Pipfile
:
pipenv install # you can also add the '--dev' flag to install the dev dependencies
If you want to ensure that the dependencies are installed exactly from Pipfile.lock
, you can run the following:
pipenv sync
In the case that a Pipfile
doesn't exist, you can create one after installing at least one package:
pipenv install <package>
You can also import a requirements.txt
file to create your Pipenv
file from there:
pipenv install -r path/to/requirements.txt
Generating a Pipenv.lock
lock file is as follows:
pipenv lock # you can include pre-released with the '--pre' flag
You can install or uninstall any package with the following commands (similar to pip):
pipenv install <package>
pipenv uninstall <package>
You can also install specific or semi-specific versions with the following modification:
pipenv install "requests~=1.2"
pipenv install "requests>=1.4"
You can find more info about this here.
If you need to nuke your virtual environment and start from scratch, you can run the following command. NOTE: THIS IS A DESTRUCTIVE ACTION
pipenv uninstall --all
You can check your dependencies for security vulnerabilities:
pipenv check
You can also see a dependency tree of your project:
pipenv graph
Since we don't have easy access to the virtual environment folder, the procedure to running the project has changed slightly. There's two ways to do so:
- Activate the virtual environment and then run the project normally:
pipenv shell
python -m webapp.app
- Run a command directly in the virtual environment without explicitly activating the env itself:
pipenv run python -m webapp.app
Note: You can run any command in the virtual environment via pipenv run [command]