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:
Following is the list of all the topics that we are going to cover in Python Installation Guide. You can click on the topics to jump to a specific one.
In our Python Data Science tutorial, we will be using windows system and one of the best Python IDE for windows that is Jupyter Notebook for which we will be installing Anaconda. So, let’s get started!
For Windows operating system, the installation process is as under:
Now, once the installation set up start, we need to follow the following installation steps:
Step 1: A Setup pop-up window – Python 3.7.0 (32-bit) will appear. Here we need to ensure that we have checked the checkboxes for Install launcher for all users (recommended) and the 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 the 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 you the various components it is installing, and it will move the progress bar towards completion. Soon, a new Python 3.7.0 (32-bit) Setup pop-up window will appear with a Setup was successfully message.
Step 4: Once the installation is done, click on Close button. And now Python should now be installed.
Step 5: Now, we 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 appears, and inside the window; on the first line we have a text Python 3.7.0 … from here we can notice that it should also say 32 bit.
Inside the window, at the bottom left, is the prompt >>>: type exit() to this prompt and here press enter to terminate Python.
Now, we should keep the file python-3.7.0.exe somewhere on our computer in case if you need to reinstall Python.
To write a Python script file we can use any text editing software. For that, we just have to save it with the .py extension. But using a Python IDE can make developer life a lot easier. IDE is a software that provides useful features like hinting code, highlighting and checking syntax, file explorers etc. to the programmer for application development.
Some of the popular free Python IDE are PyCharm, Spyder, Rodeo and Jupyter Notebook. Jupyter NoteBook is one of the best among them.
Jupyter Notebook is a web application based on a server-client structure which allows you to create and manipulate notebook documents – or just “notebooks”.
It provides you 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/ and select the version then click on Download
Step 2 – Execute the Exe file, install Anaconda3 popup window will appear. Here select Install for me only and then click on Continue
Step 3 – Next Anaconda setup window will appear here select All user and click on Next
Step 4 – A advance 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\
Once we are done with the successful installation of Python and Anaconda in our system.
Now that we have Python and Jupyter Notebook up and running, we can continue to write our first Python program – Hello Learners! Example
Simply launch the Jupyter Notebook kernel and in the code line type print “Hello Learners!”
Then click on Run
Congratulations, your first Python program is executed.
Now, we will discuss the installation of Python on Linux Machine
Step 1 – First you have to navigate to the Python download site with your browser. Here you see different OS select the Linux/UNIX .
Step 2 – Now, you will be navigated to the Python Source Releases. Here, click the appropriate link for your version of Linux:
Step 3 – Then pop up will appear whether you want to open or save the file, choose Save. The Python source files begin downloading. Be patient: The source files require a minute or two to download.
Step 4 – Now, double-click the downloaded file. The Archive Manager window opens. After the files are extracted, you see the Python 3.3.4 folder in the Archive Manager window. Again double-click the Python 3.3.4 folder. Here, the Archive Manager extracts the files to the Python 3.3.4 subfolder of your home folder.
Step 5 – Now, open a copy of Terminal. Here, if you have never built any software on your system before, then you must install the build-essentials, like SQLite, and bzip2 otherwise you are the Python installation will fail. And if you have already installed them, you can skip 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 terminal changes directories to the Python 3.3.4 folder on your 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 a minute — it depends on the processing speed of your system.
Step 12 – Now, type sudo make altinstall and press Enter. Here, the system may ask you for your administrator password. Type your password and press Enter. At this point, a number of tasks take place as the system installs Python on your system.
Now, your Python is up and running. You can execute your 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.
Now, we will discuss how to install Python 3 on your local macOS machine and we 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 Mac OS X first you have to install Xcode then you have install Homebrew and Python
We require Xcode to install Homebrew and Python. You can download Xcode from the App Store.
To install Xcode from the App Store is a time-consuming process after a lengthy download and install process, open a terminal and type the following command to install Xcode Command Line tools and in the next step we will install Homebrew:
Homebrew is a package manager for OSX. We can use it to install specific versions of python that coexist with and prevent 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:
Now that 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.
Now, your python is up and running on Mac OS. You can execute your 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 key and the Command Prompt will appear like:
Then execute your Python Programs as follows –
You can write Python program in a separate file using any editor of OS via this mode
Type print ‘hello world’ in notepad and save it to with .py extension suppose this 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 the python as follows:
Click on Start button -> All Programs -> Python -> IDLE (Python GUI)
In IDE you can use
This brings us to the end of this module in the Python Tutorial. We will be starting with python syntax and everything that you need to know to start writing programs in Python. See you there.
Further check our Python course for certification and prepare yourself with our free Python interview questions listed by the experts.
Download Interview Questions asked by top MNCs in 2019?