Python Setup
Contents:
Installing Python with Homebrew
[Optionally], you can alias python3 to just python by adding to your .zshrc or equivalent:
Virtual ENV Install / Config
Using virtual environments is recommended to avoid mismatched dependencies between projects. For this, we use virtualenvwrapper, which builds upon virtualenv.
Complete the setup according to their latest docs.
Then you need to adjust your .zshrc (or equivalent) to source virtualenvwrapper when starting your shell:
# PYTHON VIRTUALENVWRAPPER SETUP ==============================================
export VIRTUALENVWRAPPER_PYTHON=/opt/homebrew/bin/python3 # Adjust for your system / architecture
export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/Projects # Your default project dir
source /opt/homebrew/bin/virtualenvwrapper.sh # Adjust for your system / architecture
Note: These values are for an M1 MacBook Pro, and might be different in other environments, particularly the
/opt/homebrew/binpath. You can find where this ended up by runningfind / -name virtualenvwrapper.sh(source).
Usage
To create / activate / deactivate a virtual environment:
# create a new environment
mkvirtualenv <project_name>
# switch to some other environment
workon <some_other_project_name>
# and then to deactivate:
deactivate
Most shells will show some sort of indication of what virtual env you are in.
Installing Python on Windows
To install Python for Windows, go to the Python website here and download Python and its accompanying IDLE.
Navigate then to this website to find step by step instructions on how to download PIP onto your computer.
Installing PIP on Windows
-
First, download the
get-pip.pyinstallation script. The binary data is a base85 encoding of a zip file containing the entire copy of pip. Select the entire page with CTRL+A and CTRL+C and paste it into a Python .py file. Save the file as get-pip.py in the same folder as your Python program is stored in. -
In a CMD prompt / Bash terminal, 'cd' to the path where the new get-pip.py file is saved
-
Run the command
python get-pip.pyin the terminal and then pip will begin installing. -
Once pip has successfully installed, run the command
pip -Vto verify the installation process.
Installing Python Dependencies using pip
In your CMD prompt / Bash terminal 'cd' to where the dev-docs repository is cloned in your computer. Run the command below to install required programs.