This Gist will just go through the basics of setting up Python in such a way that it is easily maintainable.
Table of Contents:
On Windows download a copy of Cygwin. This is a UNIX emulator for Windows which is much easier in my opinion.
It is easy enough to go to the Python website and download the latest version of Python - but this does not necessarily play nicely with your system's version of Python. It also makes it much more difficult to run different versions of Python. There are two methods which can be used to install Python properly, Anaconda and PyEnv.
My preference is to use PyEnv - but Anaconda might be easier to set up on Windows.
Anaconda can be installed from this website.
Note: Make sure you download the 64-Bit version.
Conda provide a great starting guide which you can find here.
There is also a useful cheatsheet which can be found here
Anaconda is quite a large package which includes lots of unnecessary add-ons. Peronsally, I prefer to use PyEnv - this has the added benefit that it's super easy to switch between different versions of Python.
Installing on MacOS:
PyEnv can easily be installed using the brew package manager:
$ brew update
$ brew install pyenvYou should also install the Python dependencies:
$ xcode-select --install
$ brew install openssl readline sqlite3 xz zlibAlternatively you can run a script I developed:
setup_python.sh
Add PyEnv to PATH:
$ echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc
$ echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrcAdd pyenv init to your shell:
$ echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.zshrcRestart your shell so the changes can take place. You can either restart the terminal or run the command:
$ exec "$SHELL"Installing Python:
Now PyEnv has been installed, a relevant Python version can be installed:
$ pyenv install 3.8.5You can now set this to be your global Python version:
$ pyenv global 3.8.5Now you have Python installed it's time to take a look at using virtual environments...