Here I describe what I feel is the appropriate way to install python.
How this method differs than using a straight up installer is that python is installed in layers, rather than directly to your system.
https://www.python.org/downloads/
Python is not inherently user friendly, requiring some knowledge and some patience.
This method, if done correctly, will create an organized environment for your projects, saving you from the initial chaos of python versioning conflicts that most users experience.
Python was designed to work in Unix-like shells.
Unix is a type of operating system (OS) that follows a specific philosophy.
MacOS is a unix operating system, whereas Linux is not technically Unix, but unix like.
A shell is an interface that communicates with your operating system.
Its called a shell because its like an outer layer of your OS.
From the end-user's perspective, the shell is the command language that you see in a terminal application.
By default MacOS and most Linux distributions use Bash as their default shell in their default terminal application.
Python works well on native MacOS and Linux operating systems.
Even though python runs well on MacOS, MacOS is not setup to install python in the recommended way, a package manager.
A package manager is a installation interface that is ran through the shell.
MacOS has a community developed package manager called Homebrew or brew for short.
The initial step for MacOS users is to install Homebrew.
Windows is not a Unix-like system and does not have a Unix-like shell.
Thus, Python can be tricky to setup on Windows.
However, Windows 10 allows you to run instances of Linux in a subsystem.
Ubuntu is the most popular Linux distribution.
The initial step for Windows users is to install a Linux subsystem, so that you have access to a Unix-like shell.
Python is a very popular language and developed by the community.
It has changed a lot between different versions, leaving some applications incompatible with newer versions.
To further complicate things, two versions, python 2 and python 3, were being supported simultaneously for a long time.
That said, its tricky to say there is a right version of python, but rather different versions that suite specific needs.
Python developers have created a couple of tools to make it easier to install multiple versions of python simultaneously and switch between the two.
There are multiple applications to these different python environments.
Pyenv is a simple application that lets you both install and switch which python version you are using.
I personally recommend installing Python via pyenv.
Pyenv will be your package manager for Python proper only.
Each version of python that you install via pyenv will provide its own version of pip, a Python specific package manager, that is, a package manager for Python libraries.
Pip is what you will use to install python tools that are generally available to a given version of python.
One final layer of installation is recommended. Where pyenv creates environments for python versions, virtualenv creates environments for individual projects, within a pyenv environment.
A REPL or Read-Eval-Print-Loop is a command line interface for interpreted languages like python.
Python has a built in REPL that opens when you run in terminal
python
You can interactively run python commands and see their output.
The builtin REPL is strictly limited to python commands.
ipython is a REPL with some added features, that make it more integrated with your operating system.
Here is a summary of what this installation looks like
MacOS/Linux
-Shell
–Pyenv
—Python 3.9.1
—-VritualEnv
—–MyProject
——Libraries: Numpy, Pandas, etc..
——Project Code
Windows10 Operating System
-WindowsTerminal
–Ubuntu
—Shell
—-Pyenv
—–Python 3.9.1
——VritualEnv
——-MyProject
——–Libraries: Numpy, Pandas, etc..
——–Project code
Requirements:
Windows 10, with at least October 2017 update
Enable Windows Subsystem Linux
Install version 2, if that doesn't work, install version 1.
WSL2: in powershell run
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
WSL1: in powershell run
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
Install Ubuntu to WSL from Windows store
https://www.microsoft.com/en-us/p/ubuntu/9nblggh4msv6#activetab=pivot:overviewtab
Open Ubuntu from program files
Hit windows key, type Ubuntu, open Ubuntu application
Wait for Ubuntu to start up for the first time.
Update Ubuntu
sudo apt update
sudo apt upgrade
In terminal run
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
bash
For more details and/or other operating systems see https://github.com/pyenv/pyenv#command-reference
Install pyenv via brew
brew update
brew install pyenv
bash
Setup pyenv to work with your shell
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.profile
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.profile
echo 'eval "$(pyenv init --path)"' >> ~/.profile
echo 'if [ -n "$PS1" -a -n "$BASH_VERSION" ]; then source ~/.bashrc; fi' >> ~/.profile
echo 'eval "$(pyenv init -)"' >> ~/.bashrc
Fully close your terminal and open a new one
Install pyenv
apt install pyenv
Setup pyenv to work with your shell
sed -Ei -e '/^([^#]|$)/ {a \
export PYENV_ROOT="$HOME/.pyenv"
a \
export PATH="$PYENV_ROOT/bin:$PATH"
a \
' -e ':a' -e '$!{n;ba};}' ~/.profile
echo 'eval "$(pyenv init --path)"' >>~/.profile
echo 'eval "$(pyenv init -)"' >> ~/.bashrc
In terminal run
brew install git wget
In terminal run
apt install git wget
Install a specific version of python, e.g. 3.9.1
pyenv install 3.9.1
Set your python version default
pyenv global 3.9.1
pip3 install virtualenv
pip3 install virtualenvwrapper
Install pyenv and virtualenv linker.
For Mac run, in terminal run
brew install pyenv-virtualenv
For Linux & WSL (Windows), in terminal run
git clone https://github.com/pyenv/pyenv-virtualenv.git $(pyenv root)/plugins/pyenv-virtualenv
Setup virtualenv with your shell
For Mac, run
echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.profile
For other OSs, run
echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc
Create a new environment
pyenv virtualenv 3.9.1 myNewEnvironment
Create a new project directory
mkdir myProject
Change directory into the new project director
cd myProject
give the directory a local environment
pyenv local myNewEnviornment
pyenv activate myNewEnv
With your setup virtual environment, run
pip install ipython jupyter numpy matplotlib pandas
Python does not have its own editor
Notepad++ is quick to install
https://notepad-plus-plus.org/downloads/