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 the command terminal to start python 3. If you still run command python, it will execute python2. This is the same as in Linux.

1.2 Install Python on Windows

  1. First, download the 64-bit installer or 32-bit installer for Python 3.7 from the official Python website based on your Windows version (64-bit or 32-bit).
  2. 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.
  3. If you do not check the Add Python 3.7 to PATH checkbox, you will encounter an error when you run python in the command line, because you do not add the python executable file path in the PATH environment variable.

2. Run Python

  1. After successful installation, open the command prompt window, when you type in the command python and see the below output message, it means python has been installed successfully.
    (MyPythonEnv) C:\Users\zhaosong>python
    Python 3.8.8 (default, Apr 13 2021, 15:08:03) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
    Type "help", "copyright", "credits" or "license" for more information.
  2. 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 press the enter key.
  3. 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 the 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 windows explorer and click the Properties menu item in the popup menu list.
  2. Click the Advanced system settings —> Environment Variables, then double click the Path variable name in the popup dialog.
  3. Then add python bin directory path at the end of the Path values, use ; to separate. Now open a dos window, and type the command python, the error will not come out anymore.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.