Python - General

This assumes you are using Python 3. (I am also using Git Bash as my shell)

Venv

Setup a virtual environment

It is a good idea to install packages in virtual environment so that we do not clutter our main python install, and we can easily get rid of the packages if we want. First we need to create the virtual enveronment. Navigat to a folder where you want your venv and type cd into it and then run:

winpty python3 -m venv /path/to/new/virtual/environment

Note if you use Git Bash you need to use the winpty utility to run some programs. See here for more info

What this will do is to create a virtual environment (inside a new folder called venv) that will be placed inside the current directory. The next step is to activate the environment, we do this by runnung:

. venv/Scripts/activate

If the venv was activated your terminal should display (venv) in front of the drive letter.

If you wish to deactivate the venv run this:

deactivate

Use the venv in SublimeText

There are probably better ways of running a venv in sublime but this brute force method works fine. Just add a new build system and point it to the python.exe in you venv.

{
    "cmd": ["C:/path/to/venv/Scripts/python.exe", "-u", "$file"],
    "selector": "source.python",
    "file_regex": "^\\s*File \"(...*?)\", line ([0-9]*)"
}

Pip

To see which packages that are already installed we can ran:

pip list
Package    Version
---------- -------
pip        20.2.1
setuptools 49.2.1