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:
Watch this Python Installation video
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.
In this Python Tutorial, You will be using Windows system and the best Python IDE for Windows that is Jupyter Notebook for which You will be installing Anaconda. So, let’s get started!
For Windows operating system, the installation process is as follows:
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 installation
The following pop-up window will appear.
This pop-up window will be with the title C:\Users\AppData\Local\Programs\Python\Python37-32\python.exe, 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.
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!
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\
You are done with the successful installation of Python and Anaconda in our system, Now let’s set up Jupyter Notebook.
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.
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:
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!
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.
This command will install the latest version of Python in your Ubuntu system. You can check the version using the command mentioned above.
sudo apt-get upgrade python3
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!
Python programs can execute in three different modes which are –
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:
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!
Download Interview Questions asked by top MNCs in 2019?