Skip to content

Python Cheatsheet

Windows Python Setup

# Type `python` in shell and install via Windows Store
pip install pipenv

# Add pipenv `Scripts` directory to Path environment variables


# Refresh env vars
RefreshEnv.cmd

Python Development Notes

pipenv

Installation

WSL

apt update && apt install pipenv

Importing requirements.txt

# Importing from a requirements.txt
pipenv install -r requirements.txt

Windows Setup

$ sudo apt-get install -y make build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev \
libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python-openssl
curl https://pyenv.run | bash

Introduction

When starting a Python project, you don't want to use the system Python interpreter. You want to have a separate, isolated install for your project.

This is done using pyenv.

pipenv --python 3.9.7
pipenv install <dependencies>

git init .
git add . 
git commit -m "Initial commit."

Obsolete

References - https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/

Windows Installation python -m pip install --upgrade pip python -m pip install --user virtualenv python -m venv env

Mac Installation python3 -m pip install --upgrade pip python3 -m pip install --user virtualenv python3 -m venv env

Usage .\env\Scripts\activateWindows Python Setup

References - https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/

Installation python -m pip install --upgrade pip python -m pip install --user virtualenv python -m venv env

Usage .\env\Scripts\activate


Last update: 2023-03-30