Python Installation and Setup Guide
To get started working with Python 3, first of all You will need to have access to the Python interpreter. There are numerous ways to accomplish this:
- You can directly obtain it from the Python Software Foundation Youbsite at Python.org.
- In operating systems like Linux, there will be a package manager which can be run to install Python.
- On MacOS, to install Python 3, first You have to install a package manager called Homebrew. This will be discussed later in the relevant section of this tutorial.
- On mobile operating systems like Android and iOS, You can install Python apps which provide an environment for Python programming.
- Even there are so many Youbsit es that allow us to access a Python interpreter online without any installation on your system.
Watch this Python Installation video:
Go for the most professional Python Course Online in Toronto for a stellar career now!
Now, You will see the step-by-step installation and set-up of a working Python 3 distribution on Windows, MacOS, and Linux.
Following is the list of all topics covered in this Python installation guide. You can click on the topics to jump to a specific one.
- Install Python on Windows
- Install Anaconda Python and Jupyter Notebook
- Install Python in Linux
- Install Python in Ubuntu
- Install Python on Mac OS X
Install Python on Windows
For Windows operating system, the installation process is as follows:
- To install Python, firstly You need to go to the Download Python page from its official site python.org/download and click on the latest version
- Once the Python distribution download is completed, then double-click on the executable downloaded software, and then click on Run
Now, once the installation set up starts, You need to follow the below-mentioned installation steps:
Step 1: A pop-up window, Python Version 3.7.0 (32-bit) Setup, will appear. Here, You need to ensure that You have checked the checkboxes for ‘Install launcher for all users (recommended)’ and for ‘Add Python 3.7 to PATH’ at the bottom
Step 2: Now, a User Account Control pop-up window will appear, posing the question, ‘Do you want to allow the following program to make changes to this computer?’ Click on Yes
Step 3: Now, a new Python 3.7.0 (32-bit) Setup pop-up window will appear with a ‘Setup Progress’ message and a progress bar. During the installation, it will show us various components it is installing, and it will move the progress bar toward completion. Soon, a new Python 3.7.0 (32-bit) Setup pop-up window will appear with a ‘Setup was successful’ message
Step 4: Once the installation is done, click on the Close button. And now, Python is successfully installed
Step 5: Now, You will try to verify the installation
- Navigate to the directory:
or to whatever directory Python was installed (see Step 3 of the installation process)
- Double-click on the icon/file python.exe
The following pop-up window will appear.
This pop-up window will be with the title:
and inside the window, on the first line, You will get a text ‘Python 3.7.0…’. From here, You can notice that it also says ‘32 bit’.
Inside the window, at the bottom left, the prompt, ‘>>>’: type exit() to this prompt and press Enter to terminate Python.
Now, You should keep the file python-3.7.0.exe somewhere on our computer in case You need to reinstall Python.
To write a Python script file, You can use any text editing software. For that, You just have to save it with the .py extension. But, using a Python IDE can make developers’ life a lot easier. IDE is a software that provides useful features like hinting code, highlighting and checking syntax, file explorers, etc. to programmers for application development.
Watch this Matplotlib Python Tutorial Video for Beginners:
Become a professional Python Programmer with this complete Python Training in Singapore!
Some of the popular free Python IDEs are PyCharm, Spyder, Rodeo and Jupyter Notebook. Jupyter Notebook is one of the best among them.
Jupyter Notebook is a Youb application based on a server–client structure which allows us to create and manipulate notebook documents—or just ‘notebooks.’
It provides us with an easy-to-use, interactive Data Science environment across many programming languages that doesn’t only work as an IDE but also as a presentation or education tool. This tool is perfect for those who are just starting out with Data Science!
Installing Anaconda Python and Jupyter Notebook
Setting up Anaconda Distribution
Step 1: To install Anaconda Python, just go to https://www.anaconda.com/download/, select the version, and then click on Download
Step 2: Execute the Exe file, the Install Anaconda3 pop-up window will appear. Here, select Install for me only and then click on Continue
Step 3: Next the Anaconda setup window will appear; here, select All users and click on Next
Step 4: An advanced installation window will appear; here, select Add Anaconda to my PATH environment variable and click on Install
Anaconda will get installed in our user home directory:
Windows 10: C:\Users\<your-username>\Anaconda3\
Go for this in-depth job-oriented Python Training in Hyderabad now!
Steps to Launch Jupyter Notebook
You are done with the successful installation of Python and Anaconda in our system, Now let’s set up Jupyter Notebook.
- To launch Jupyter Notebook via command line, simply open our Anaconda Windows Command Prompt. Here, type and run Jupiter Notebook
- A Jupyter Notebook dashboard will open on our default Youb browser
- Here, click on New→ then select Python 3
- A new python kernel will get opened, and You are ready to write a new program
Running a Simple Program in Python
Now that You have Python and Jupyter Notebook up and running, You can continue to write our first Python program, Hello Learners! as an example
Simply launch the Jupyter Notebook kernel and in the code line type print “Hello Learners!”
Then click on Run
Congratulations, our first Python program is executed.
We have the perfect professional Python Course in Bangalore for you!
Watch this Python Django Tutorial Video for Beginners:
How to Install Python in Linux
Okay, so How to Install Python? Let’s talk about the installation of Python on Linux Machine.
Step 1: First, You have to navigate to the Python download site with our browser. Here, You will see different operating systems to choose from; select Linux/UNIX
Step 2: Now, You will be navigated to Python Source Releases. Here, click on the appropriate link for our version of Linux:
- Python 3.7.2 compressed source tarball (any version of Linux)
- Python 3.7.2 gzipped source tarball (better compression and faster download)
Step 3: A pop up will appear asking whether You want to open or save the file; choose Save. Python source files will begin downloading. Be patient: source files require a minute or two to download
Step 4: Now, double-click on the downloaded file. The Archive Manager window opens. After the files are extracted, You will see the Python 3.3.4 folder in the Archive Manager window. Again, double-click on the Python 3.3.4 folder. Here, the Archive Manager extracts the files to the Python 3.3.4 subfolder of our home folder
Step 5: Now, open a copy of Terminal. Here, if You have never built any software on our system before, then You must install build-essentials, like SQLite and bzip2, otherwise our Python installation will fail. And, if You have already installed them, You can skip the below steps and move to Step 9 to begin working with Python immediately
Step 6: Now, type sudo apt-get install build-essential and press Enter. Here, Linux installs the Build Essential support required to build packages
Step 7: Now, type sudo apt-get install libsqlite3-dev and press Enter. Here, Linux installs the SQLite support required by Python for database manipulation
Step 8: Now, type sudo apt-get install libbz2-dev and press Enter. Here, Linux installs the bzip2 support required by Python for archive manipulation
Step 9: Type CD Python 3.3.4 in the Terminal window and press Enter. Here, the terminal changes directories to the Python 3.3.4 folder on our system.
Step 10: Type ./configure and press Enter. Here, the script begins by checking the system build type and then performs a series of tasks based on the system You’re using. This process can require few minutes because there is a large list of items to check.
Step 11: then type make and press Enter. Here, Linux executes the make script to create the Python application software. The make process can require up to 1 minute—it depends on the processing speed of our system.
Step 12: Now, type sudo make altinstall and press Enter. Here, the system may ask us for our administrator password. Type the password and press Enter. At this point, a number of tasks take place as the system installs Python on our system.
Now, our Python is up and running. You can execute our first program!
Watch this Python Inheritance Tutorial Video for Beginners:
How to Install Python in Ubuntu
Python comes pre-installed in all the versions of Ubuntu that come after Ubuntu 14.04 since the Linux distributions themselves use Python extensively for their own purposes.
- You can type the following command in Ubuntu terminal to check if the latest version of Python is already installed in your Ubuntu system or not:
python3 -v or python3 --version
- To check if you have several versions installed on your Ubuntu, type the following command in your Ubuntu terminal:
apt list --installed | grep python
- To access Python 2 in Ubuntu, just type the following command in the Ubuntu terminal:
- To access Python 3 in Ubuntu, type the following command in Ubuntu terminal:
- If by any chance, your Ubuntu system does not have Python installed, or you are using older version of Ubuntu, then you can use the command mentioned below to install it.
sudo apt-get install python3
This command will install the latest version of Python in your Ubuntu system. You can check the version using the command mentioned above.
- In case you have Python already installed but it’s not the latest version, then you can upgrade you Python package using the command mentioned below.
sudo apt-get upgrade python3
How to Install Python on MacOS X
Now, You will learn how to install Python 3 on our local MacOS machine, and You will also set up a programming environment via the command line. To do installation, You will need administrative access that is connected to the Internet.
To install Python on MacOS X, first, You have to install Xcode, then You have to install Homebrew, and then Python.
You require Xcode to install Homebrew and Python. You can download Xcode from the App Store.
Installing Xcode from the App Store is a time-consuming process. After the lengthy download and install processes, You have to open a terminal and type the following command to install Xcode Command Line tools, and in the next step You will install Homebrew.
Homebrew is a package manager for OSX. You can use it to install specific versions of Python that coexist with, and prevent the pollution of, the system Python.
Now, go to https://brew.sh/
From here, follow the directions to install Homebrew. Once done, paste this line into a terminal:
/usr/bin/ruby -e “$(curl -fsSL https://abc.com/Homebrew/install/master/install)”
Now our Homebrew is installed, which is used to install Python. The OSX system will still use the built-in system Python, but anything You do will use the newly installed Python
Install latest python 3: brew install python Install latest python 3.x brew install python3
Now, our Python is up and running on MacOS. You are ready to execute our first program!
Watch this Python Pandas Tutorial Video for Beginners:
Python First Program execution
Python programs can execute in three different modes which are –
- Interactive Mode
- Script Mode
- Using IDE
You can enter python in the command prompt and start working with Python.
Press Enter and the Command Prompt will appear as below:
Now, execute our Python programs as follows:
You can write Python programs in a separate file using any editor of OS via this mode
For example, type print ‘hello world’ in notepad and save it with .py extension. In this example, the file name is hello.py.
Then, run this file in command prompt by typing Python hello.py
It will print ‘hello world’ as output.
You can execute the Python program in graphical user interface. Open Python as follows:
Click on Start > All Programs > Python > IDLE (Python GUI)
In IDE, You can use:
- Interactive Mode
- Script Mode
This brings us to the end of this module in the Python tutorial. You will be starting with Python syntax and will learn everything that You need to know about this programming language to start writing programs in Python. Let’s meet there!