Downloading and Installing Python!
In order to run python first we have to install python interpreter.
- Python interpreter can be downloaded from the Python Software website at python.org. It involves downloading the appropriate installer for system.
- Some operating systems like Linux, provide a package manager that can be run to install Python.
- The latest version of Python in market is Python version 3.7.
Python for Windows:
In windows we do not have python already installed.
So we have to download it from python.org website and then install it.
Step 1: Download the Python 3 Installer
- Open a browser window and navigate to the page for Windows at python.org website.
- Click in the tab which says Python Releases for Windows and then click on the link for the Latest Python 3 Release - Python 3.7.
- Select either Windows x86-64 executable installer for 64-bit or Windows x86 executable installer for 32-bit.
Note: If you choose “wrong” and would like to switch to another version of Python, you can just uninstall Python and then re-install it by downloading another installer from python.org.
Step 2: Installing Python
Then just click Install Now. That should be all there is to it. A few minutes later you should have a working Python 3 installation on your system.
Note: Check the box that says Add Python 3.x to PATH as shown to ensure that the interpreter will be placed in your execution path otherwise it will be error.
Linux
In Linux distribution has Python installed already, but it probably won’t be the latest version, and it may be Python 2 instead of Python 3.
To find out what version(s) you have, open a terminal window and try the following commands:
python2 --version
python3 --version
One or more of these commands should respond with a version, as below:
$ python3 --version
Python 3.6.5
If the version shown is Python 2.x.x or a version of Python 3 that is not the latest then you will want to install the latest version. The procedure for doing this will depend on the Linux distribution you are running.
Note that it is frequently easier to use a tool called
pyenv
to manage multiple Python versions on Linux. To learn more about it, see our article here.Ubuntu
Depending on the version of the Ubuntu distribution you run, the Python install instructions vary. You can determine your local Ubuntu version by running the following command:
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.4 LTS
Release: 16.04
Codename: xenial
macOS / Mac OS X
While current versions of macOS include a version of Python 3 which is a good news.
The best way we found to install Python 3 on macOS is through the Homebrew package manager.
Step 1: Install Homebrew (Part 1)
To get started, you first want to install Homebrew:
- Open a browser and navigate to http://brew.sh/. After the page has finished loading, select the Homebrew bootstrap code under “Install Homebrew”. Then hit Cmd+C to copy it to the clipboard. Make sure you’ve captured the text of the complete command because otherwise the installation will fail.
- Now you need to open a Terminal.app window, paste the Homebrew bootstrap code, and then hit enter key. This will begin the Homebrew installation.
- If you’re doing this on a fresh install of macOS, you may get a pop up alert asking you to install Apple’s “command line developer tools”. You’ll need those to continue with the installation, so please confirm the dialog box by clicking on “Install”.
At this point, you’re likely waiting for the command line developer tools to finish installing, and that’s going to take a few minutes.
Step 2: Install Homebrew (Part 2)
You can continue installing Homebrew and then Python after the command line developer tools installation is complete:
- Confirm the “The software was installed” dialog from the developer tools installer.
- Back in the terminal, hit enter key to continue with the Homebrew installation.
- Enter your user account password and hit enter key to continue.
- Once the installation is complete, you’ll end up back at the command prompt in your terminal window.
Whew! Now that the Homebrew package manager is set up, let’s continue on with installing Python 3 on your system.
Step 3: Install Python
Once Homebrew has finished installing, return to your terminal and run the following command:
$ brew install python3
This will download and install the latest version of Python.
You can make sure everything went correctly by testing if Python can be accessed from the terminal:
- Open the terminal by launching Terminal.app.
- Type
pip3
and hit enter key. - You should see the help text from Python’s “Pip” package manager. If you get an error message running
pip3
, go through the Python install steps again to make sure you have a working Python installation.
Online Python Interpreters
There are several web sites available where you can interact with a Python interpreter online:
- Python Anywhere: www.pythonanywhere.com
- Python.org Online Console: www.python.org/shell
- Repl.it: repl.it
- Trinket: trinket.io
- Python Fiddle: pythonfiddle.com
0 Comments