Skip to content

Instantly share code, notes, and snippets.

@andrew-rietz
Last active July 25, 2021 16:37
Show Gist options
  • Save andrew-rietz/0a3d83a3819c8eadfadab9136a634e6b to your computer and use it in GitHub Desktop.
Save andrew-rietz/0a3d83a3819c8eadfadab9136a634e6b to your computer and use it in GitHub Desktop.

Example Pipenv Workflow

Clone / create project repository:
$ cd myproject

Install from Pipfile, if there is one:
$ pipenv install

Or, add a package to your new project:
$ pipenv install <package>

This will create a Pipfile if one doesn’t exist. If one does exist, it will automatically be edited with the new package you provided.

Next, activate the Pipenv shell:

$ pipenv shell
$ python --version

This will spawn a new shell subprocess, which can be deactivated by using exit.

Specifying Versions of Python

To create a new virtualenv, using a specific version of Python you have installed (and on your PATH), use the --python VERSION flag, like so:

Use Python 3:
$ pipenv --python 3

Use Python3.6:
$ pipenv --python 3.6

Use Python 2.7.14:
$ pipenv --python 2.7.14

Configuring VS Code to Use Your Pipenv environment

After you've created a pipenv environment, add the location of your environments python executable to the VSCode settings.json file
Get your pipenv executable location:
pipenv --py

Copy and paste that location into your settings.json file:

{
    "python.pythonPath": "<<PATH_FROM_ABOVE>>"
}

https://www.benjaminpack.com/blog/vs-code-python-pipenv/

Additional resources:

https://pipenv.kennethreitz.org/en/latest/basics/
https://realpython.com/pipenv-guide/#example-usage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment