Skip to content

Instantly share code, notes, and snippets.

@ryansutc
Last active September 13, 2022 11:47
Show Gist options
  • Save ryansutc/270e50d1b1ec933ecee9b71db22c497a to your computer and use it in GitHub Desktop.
Save ryansutc/270e50d1b1ec933ecee9b71db22c497a to your computer and use it in GitHub Desktop.
A Quick Cheatsheet for Python PIP and pipenv Commands

Python PIP Cheatsheet


Creating/Starting a Project

get dependencies for an existing repo in your virtual env:

pipenv install

confirm you've got a virtual env:

pipenv run which python

download your development dependency:

pipenv install --dev [yourrepo]

activate virtual environment:

pipenv shell

close, deactivate virtual environment: (close shell or close subshell via:)

exit

review a package:

pip show [packagename]

Creating Packages

Generate a distribution archive (wheel/tar files)

python setup.py sdist bdist_wheel # from setup.py dir

Upload the distribution archive to Pypi

twine upload --repository-url https://test.pypi.org/legacy dist/*

Building a Package/Library to an App

using pyinstaller to create a build (will create a build and dist folder):

pyinstaller [yourmainscript.py]

Other/Misc

figure out where your user packages are installed

python -m site --user-base

blow away your virtual env (if pipfile exists):

pipenv --rm

If not, just delete directory manually.

@ryansutc
Copy link
Author

ryansutc commented Jan 1, 2020

Now that all the cool kids are using pipenv instead, we're doing that. Remember:
by default pipenv wants to set up your Virtual Env outside the project by default. To "fix" this annoyance, do:
PIPENV_VENV_IN_PROJECT=1
in your computer user environment variables.

https://pipenv.kennethreitz.org/en/latest/install/#virtualenv-mapping-caveat

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