Skip to content

Instantly share code, notes, and snippets.

@hlombroso
Last active March 12, 2022 03:37
Show Gist options
  • Select an option

  • Save hlombroso/96c7f29d5d025564a5fdf3bc8d521dbe to your computer and use it in GitHub Desktop.

Select an option

Save hlombroso/96c7f29d5d025564a5fdf3bc8d521dbe to your computer and use it in GitHub Desktop.

Revisions

  1. hlombroso revised this gist Mar 12, 2022. 1 changed file with 12 additions and 4 deletions.
    16 changes: 12 additions & 4 deletions Pipenv Cheat Sheet.md
    Original file line number Diff line number Diff line change
    @@ -28,15 +28,15 @@ pipenv run python
    or
    pipenv run python script.py

    ## Install packages from requirement.txt
    pipenv install -r location/to/requirement.txt
    ## Install packages from requirements.txt
    pipenv install -r location/to/requirements.txt


    ## Check local packages
    pipenv lock -r

    ## Import local packages to requirement.txt file
    pipenv lock -r > requirement.txt
    ## Import local packages to requirements.txt file
    pipenv lock -r > requirements.txt


    ## Install a package only in a dev environment
    @@ -76,6 +76,14 @@ pipenv lock
    ## Ignore pipfile (while installing on server)
    pipenv install --ignore-pipfile

    ## Get path of virtual environment in pipenv
    ### Get Path of the project
    pipenv --where

    ### Get path of virtual environment
    pipenv --venv


    ## How to push to production
    -Update pipfile.lock file:
    [pipenv lock]
  2. hlombroso created this gist Aug 1, 2021.
    93 changes: 93 additions & 0 deletions Pipenv Cheat Sheet.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,93 @@
    ## Tutotial url
    https://www.youtube.com/watch?v=zDYL22QNiWk&t=151s


    ## Install pipenv
    pip3 install pipenv

    ## Install a package
    pipenv install package_name

    ## Activate environment
    pipenv shell

    ## Deactive environment
    exit

    ## Check version of Python
    python --version

    ## Check executable path
    python
    - import sys
    - sys.executable
    - quit()

    ## Run command in the environment without activating it
    pipenv run python
    or
    pipenv run python script.py

    ## Install packages from requirement.txt
    pipenv install -r location/to/requirement.txt


    ## Check local packages
    pipenv lock -r

    ## Import local packages to requirement.txt file
    pipenv lock -r > requirement.txt


    ## Install a package only in a dev environment
    pipenv install package_name --dev

    ## Uninstall a package
    pipenv uninstall package_name

    ## How to make change in the pipfile
    Example change the version of python_version
    - Open pipfile and change the version (3.7 > 3.6)
    - recreate the environment by runnning
    pipenv --python 3.6

    ## Remove a virtual environment
    pipenv --rm

    ## Recreate virtual environment from pipfile
    pipenv install

    ## Get the path to the virtual environment
    pipenv --venv

    ## Check for known security vulnerabilities
    pipenv check

    ## Update the version of a package
    - change the version in the pipfile
    - run [pipenv install]

    ## List all the dependencies in a graph
    pipenv graph

    ## Set lockfile - before deployment
    pipenv lock

    ## Ignore pipfile (while installing on server)
    pipenv install --ignore-pipfile

    ## How to push to production
    -Update pipfile.lock file:
    [pipenv lock]
    -Push pipfile.lock for production
    -Recreate the virtual environment from pipfile.lock file
    pipenv install --ignore-pipfile

    ## Set environment variables
    - create a .env file within the project
    - add the variabale to be accessible within the environment
    SECRET_KEY="MySuperSecretKey"
    - Check the environment variabale
    pipenv run python
    - import os
    - os.environ['SECRET_KEY']