Skip to content

Instantly share code, notes, and snippets.

@r0nny8000
Last active June 9, 2025 21:17
Show Gist options
  • Save r0nny8000/76039cf1770002c0bbe44cb13fc1d334 to your computer and use it in GitHub Desktop.
Save r0nny8000/76039cf1770002c0bbe44cb13fc1d334 to your computer and use it in GitHub Desktop.
Python Cheat Sheet

Python Cheat Sheet

Pyenv

List installed versions of Python

pyenv versions

List available versions of Python

pyenv install --list
pyenv install --list | grep 3.10

Install specific Python version

pyenv install 3.10.12

Switch Python version local and global

pyenv global 3.10.12
pyenv local 3.10.12

Restart Terminal to apply changes!

Show full path to the current version of python

pyenv which python

Poetry

Init Poetry with a new folder or try to use Poetry inside the folder.

poetry new projectname
cd projectname

or

mkdir projectname
cd projectname
poetry init

Set the environment

poetry env info
poetry env use <python_version>
poetry install

Double check with

pyenv which python
poetry env info
python --version

Adding azure function as dependency to poetry from requirements.txt

poetry add azure-functions
poetry install
poetry show --tree

Switched Python Interpreter in Codium in .vscode/settings.json (or using CMD+Shift+P and "Select Interpreter")

which python

{
    "python.defaultInterpreterPath": "/Users/me/Library/Caches/pypoetry/virtualenvs/marketdata-cli-MiIDVtXc-py3.7/bin/python"
}

or just enter the path by clicking on the Python version in the bottom left corner of VSCode.

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