Now the official recommendation for managing python dependencies is pipenv
- You no longer need to use pip and virtualenv separately. They work together.
- Managing a requirements.txt file can be problematic, so Pipenv uses the upcoming Pipfile and Pipfile.lock instead, which is superior for basic use cases.
- Hashes are used everywhere, always. Security. Automatically expose security vulnerabilities.
Install on your system:#
pip install pipenv
Install a package#
pipenv install requests
- Creates a pipfile
- Creates a lockfile
Installing just for development#
pipenv install --dev nose2
Then to install with dev packages run:
pipenv install --dev
exit shell instead of deactivate
If you still want to use this relic you can:
pipenv lock -r
Use with django#
To run commands from the environment prefix the command with:
pipenv run xxx
pipenv run ./manage.py runserver
Personally I don’t like this but perhaps the advantages outway the longer command
Using Pipenv with Visual Studio#
Often times we want intellisense from the python virtualenv.
vscode we first need to find where the virtual environment is with:
cmd + shift + p and
Select Interpreter and paste the path