
Basic Pipenv workflow
Basic pipenv commands for quick recall:
Pipenv commands needed on a daily basis
To enter virtual env made by pipenv, use:
pipenv shell.To exit virtual env, use
exitcommand. Don’t usedeactivate.Use
pipenvinstead ofpipto install/uninstall packages:- You can install a package as project dependency for deployment/execution (under packages section of Pipfile using):
pipenv install flask - You can install a package as project dependency for development (under dev-packages section of Pipfile using):
pipenv install --dev pytest - To uninstall run this command (which also removes references to python package both from Pipfile and Pipfile.lock):
pipenv uninstall django
- You can install a package as project dependency for deployment/execution (under packages section of Pipfile using):
The Pipfile.lock is intended to specify, based on the packages present in Pipfile, which specific version of those should be used, avoiding the risks of automatically upgrading packages that depend upon each other and breaking your project dependency tree. This command will lookup your virtual environment folder to generate the Pipfile.lock file for you automatically, based on the currently installed versions:
pipenv lockDelete a virtual env created by pipenv:
pipenv --rmTo see location of virtual env added by pipenv:
pipenv --venv
Install Pipenv on Mac
brew install pipenv
Migrate requirements.txt to Pipenv
Navigate to your project directory and initialize a Pipfile:
pipenv install- This should automatically find requirements.txt file in pwd and convert it into Pipfile. In case it doesn’t, you can run:
pipenv install -r requirements.txt
- This should automatically find requirements.txt file in pwd and convert it into Pipfile. In case it doesn’t, you can run:
If certain dependencies are only required during development (e.g., pytest or black), you can reinstall them under dev-packages section of Pipenv using:
pipenv install <package_name> --devOnce everything is working fine, you can safely move the old requirements.txt file outside the folder, but still keep it as a backup somewhere.
Setup existing project with existing Pipenv on new laptop with fresh virtualenv
- Install pipenv, then
cdto the project directory which contains Pipenv file. - This command will create a new virtual environment as well as install dependencies listed in Pipfile.lock:
pipenv install
