How To Install Python3 On Windows And MacOS

To begin learning Python programming, you must first install Python into your computer. After you install it, you’ll get the Python interpreter (which runs the Python program). The installation includes a command-line interaction environment, and a simple integrated development environment. Because Python is cross-platform, it can run on Windows, Mac, and various Linux/Unix systems. So you can write Python programs on Windows and run them on Linux.

1. Install Python 3.7

Currently, there are two versions of Python, version 2.x and version 3.x, which are incompatible. As version 3.x becomes more and more popular, our tutorial will be based on the latest version of Python 3.7. Please make sure that the latest version of Python installed on your computer is 3.7.x.

1.1 Install Python on Mac

If you’re using a Mac, OS X>=10.9, then the native Python version is 2.7. There are two ways to install the latest Python 3.7.

  1. Download the Python 3.7 installer from the Python website, double-click to run and install.
  2. If Homebrew is installed, install it directly via the command brew install python3.
  3. After install, you need to run python3in command terminal to start python 3. If you still run command python, it will execute python2. This is same as in Linux.

1.2 Install Python on Windows

First, download the 64-bit installer or 32-bit installer for Python 3.7 from the official Python web site based on your Windows version (64-bit or 32-bit). Then, run the downloaded EXE installation package. Please check the Add Python 3.7 to PATH checkbox and then click “Install Now” to complete the installation.

python 3 windows installer

If you do not check the checkbox, you will encounter error when you run python in command line, because you do not add the python executable file path in the PATH environment variable.

2. Run Python

After successful installation, open the command prompt window, when you type in python and see below output message, it means python has been installed successfully. The prompt character >>> indicates that we are already in the Python interactive environment, and you can enter any Python code, and the result will be executed as soon as you enter return.

python install success

If you get an error message like ‘python’ is not an internal or external command, nor is it a running program or batch file. This is because Windows looks up python.exe based on a Path’s environment variable, and if it doesn’t find python.exe in the Path variable related value, it will report an error.

3. Set Python Executable Path In Environment Variable Path.

  1. Right click the Computer in explorer and click Properties menu item in the popup menu list.
    right-click-computer-properties-popup-menu-item
  2. Click Advanced system settings —> Environment Variables, then double click the Path variable name in the popup dialog.
    set-path-in-windows-system-environment-properties-1
  3. Then add python bin directory path at the end of the Path values, use ; to separate. Now open a dos window, and type python, the error will not come out.
    add-python-bin-folder-in-path-system-environment-variable-correctly