KEMBAR78
Python setup for dummies | PDF
Python Setup for
Dummies
Rajesh Rajamani
rajesh.r6r@gmail.com
Assumptions
This manual assumes that the user has reasonable privileges over the laptop or desktop where
Python is being installed. If you don’t have such privileges (such as using a work laptop) please
ask your IT team.
The steps discussed further are good for a beginner user for Python . In case you are an
advanced user , you should not be reading this manual.
These installation instructions are good for Windows 10 OS and apply fine for older versions
upto Windows 7 .
There are various modules and packages that are available to provide additional functionality to
your Python project . These are not installed by default and have to be installed separately .
It is a good idea for your laptop / desktop to have a working internet connection which allows
you to install python packages easily. Although one can install a python package offline , often
dependencies of a package become a challenge in offline installation.
Sections In This Manual
1. Installing Python
Detailed instructions to install Python
2. Installing Packages for Python
Detailed instructions to additional packages for Python
1. Installing Python
Detailed instructions to install Python
If you have already installed Python successfully , you can go to Section 2 straight away !.
Downloading the right version
Open your favorite browser and go the following url : https://www.python.org
Go to Downloads and click the button ( Python 3.7.4 ) shown below. (Note : If you want a different
version click on the “All Releases” link and explore further.)
This should download the installer in your Downloads folder . If it is successful proceed further.
Installing other versions of Python
Once you click on “All Releases” link you will be able to see a list of all the versions available for
installation. Only if you know what you are doing , proceed further. Else play safe.
Setting up things
Ensure to click the checkbox “Add Python 3.7 to PATH”. This will add the references for you .
Ensure to click the checkbox “Add
Python 3.7 to PATH”. This will add the
references for you .
We don’t want a long path such
as this to install as it would be
cumbersome later during
development. Hence click on
“Customize Installation”
Additional Features at Installation
Check all the options . They are very useful for a beginner.
Setting Up Installation Path
In this screen , there are other advanced options . But for now we have checked all that are
required for a beginner.
We have now mentioned a custom
path which is easy and short. You
can chose the path that you are
comfortable. But choose wisely.
Once everything is
set , hit the Install
button
Installation Success
You should see such a screen . Don’t worry about the path length limit .
Verifying the Physical Path ( Optional )
Note : This is the path we setup earlier
Verifying Environment Variables ( Optional )
Note : Because we wanted to add the installation folder to path in the first step.
Open System Information Under Environment Variables you can see that the path is added
2. Installing Packages for Python
Detailed instructions to install Packages for Python
An Introduction to Packages
Packages are specific features that aid you in various stages of a development .
Some exceptionally popular packages
Package Usage
numpy A fundamental package for scientific computing with Python
pandas pandas is an open source, BSD-licensed library providing
high-performance, easy-to-use data structures and data analysis
tools for the Python programming language.
nltk All Natural Language Processing tools with Python
sklearn All Machine Learning tools with Python
Installing Packages with Python
Can be classified into 2 major categories .
1. Online
Pros: Package dependencies and version compatibility are automatically taken care off.
Cons: Need a reasonable internet connection
2. Offline
Pros: Can help in an environment where internet connection is not possible ( such as
production servers )
Cons: Package dependencies and version compatibility needs to be manually managed.
Can become cumbersome when there are multiple dependencies.
Installing Python Packages when you are
“Online”
If you remember we had selected the feature “ pip “ while installing . We will be
using pip to install packages
We will now see how we can install packages with pip.
If your pip version has an upgrade , whenever you use pip it will automatically
prompt you for an upgrade.
Installing a package with pip
Lets install pandas.
Step 1 : Open Command Prompt
Step 2: Navigate to the directory C:Python37
Step 3: Enter the command pip install pandas and press Enter key.
Now let’s see what happened when I entered this command in my laptop
Installing Pandas with pip
Downloading Pandas
Downloading dependencies numpy,
python-dateutil,six,pytz
Detecting that we are using a older
version of pip and prompting for a
newer version (optional)
Installing multiple packages with pip
Sometimes you might need a lot of packages that need to be installed at once. Can we do that
with pip ?
Yes. Let’s see how we can do that.
Before starting the installation we need to create a simple text file called requirements.txt. The
name of the file can be anything as you wish , but a good practice is to use “requirements”
Here in my example , I’m installing 3 packages with 2 where the version being specified.
You can use == operator for an exact version math and >= or <= for a relative version . If you
don’t mention the version , then the latest version will be installed
How to use the requirements.txt
Let’s install packages using requirements.txt
Step 1 : Open Command Prompt
Step 2: Navigate to the directory C:Python37
Step 3: Enter the command pip install -r “D:SoftwaresPythonrequirements_3.7.txt”
Please ensure to mention the correct path of your file in the command above.
Now let’s see what happened when I entered this command in my laptop
Installing multiple packages with
requirements.txt
The last line provides vital information about the command that we fired . We fired the command with 3 packages , but
pip has managed to install not just the ones we wanted , but also the additional dependencies that are required for the
package to work well.
Now we will see how offline installation can be done.
Installing Python Packages when you are
offline
Caution : As I told earlier , offline installation means you have to physically ensure the sequence
of dependencies , versions before a particular package can be installed.
For our case , let’s install a package on offline mode. In order to install a package offline , you
have to download either the wheel file or the source file .
Wheel File :
.whl format . Compiled binary version of package . Therefore no need to compile it in .
Source File:
.py format mostly . Has to be compiled in the machine where you install it.
Let’s see an example for both.
Installing from whl file
Step 1 : Download the .whl file for the desired package
Step 2: Open Command Prompt
Step 3: Navigate to the directory C:Python37
Step 4: Enter the command pip install <Complete path with your wheel file name>
Please ensure to mention the correct path of your file in the command above.
Installing from source file
Source files are normally available as zip or tar files . Hence a couple of additional steps.
Step 1 : Download the .tar / .zip file for the desired package
Step 2: Uncompress the tar file and verify if you have the setup.py
Step 3: Open Command Prompt
Step 4: Navigate to the directory C:Python37
Step 5: Enter the command python <complete path of the setup.py> --install
Note: Because we are executing a .py file ( which is a python script) we are using the command
“python” and not “pip”
Thank You

Python setup for dummies

  • 1.
    Python Setup for Dummies RajeshRajamani rajesh.r6r@gmail.com
  • 2.
    Assumptions This manual assumesthat the user has reasonable privileges over the laptop or desktop where Python is being installed. If you don’t have such privileges (such as using a work laptop) please ask your IT team. The steps discussed further are good for a beginner user for Python . In case you are an advanced user , you should not be reading this manual. These installation instructions are good for Windows 10 OS and apply fine for older versions upto Windows 7 . There are various modules and packages that are available to provide additional functionality to your Python project . These are not installed by default and have to be installed separately . It is a good idea for your laptop / desktop to have a working internet connection which allows you to install python packages easily. Although one can install a python package offline , often dependencies of a package become a challenge in offline installation.
  • 3.
    Sections In ThisManual 1. Installing Python Detailed instructions to install Python 2. Installing Packages for Python Detailed instructions to additional packages for Python
  • 4.
    1. Installing Python Detailedinstructions to install Python If you have already installed Python successfully , you can go to Section 2 straight away !.
  • 5.
    Downloading the rightversion Open your favorite browser and go the following url : https://www.python.org Go to Downloads and click the button ( Python 3.7.4 ) shown below. (Note : If you want a different version click on the “All Releases” link and explore further.) This should download the installer in your Downloads folder . If it is successful proceed further.
  • 6.
    Installing other versionsof Python Once you click on “All Releases” link you will be able to see a list of all the versions available for installation. Only if you know what you are doing , proceed further. Else play safe.
  • 7.
    Setting up things Ensureto click the checkbox “Add Python 3.7 to PATH”. This will add the references for you . Ensure to click the checkbox “Add Python 3.7 to PATH”. This will add the references for you . We don’t want a long path such as this to install as it would be cumbersome later during development. Hence click on “Customize Installation”
  • 8.
    Additional Features atInstallation Check all the options . They are very useful for a beginner.
  • 9.
    Setting Up InstallationPath In this screen , there are other advanced options . But for now we have checked all that are required for a beginner. We have now mentioned a custom path which is easy and short. You can chose the path that you are comfortable. But choose wisely. Once everything is set , hit the Install button
  • 10.
    Installation Success You shouldsee such a screen . Don’t worry about the path length limit .
  • 11.
    Verifying the PhysicalPath ( Optional ) Note : This is the path we setup earlier
  • 12.
    Verifying Environment Variables( Optional ) Note : Because we wanted to add the installation folder to path in the first step. Open System Information Under Environment Variables you can see that the path is added
  • 13.
    2. Installing Packagesfor Python Detailed instructions to install Packages for Python
  • 14.
    An Introduction toPackages Packages are specific features that aid you in various stages of a development . Some exceptionally popular packages Package Usage numpy A fundamental package for scientific computing with Python pandas pandas is an open source, BSD-licensed library providing high-performance, easy-to-use data structures and data analysis tools for the Python programming language. nltk All Natural Language Processing tools with Python sklearn All Machine Learning tools with Python
  • 15.
    Installing Packages withPython Can be classified into 2 major categories . 1. Online Pros: Package dependencies and version compatibility are automatically taken care off. Cons: Need a reasonable internet connection 2. Offline Pros: Can help in an environment where internet connection is not possible ( such as production servers ) Cons: Package dependencies and version compatibility needs to be manually managed. Can become cumbersome when there are multiple dependencies.
  • 16.
    Installing Python Packageswhen you are “Online” If you remember we had selected the feature “ pip “ while installing . We will be using pip to install packages We will now see how we can install packages with pip. If your pip version has an upgrade , whenever you use pip it will automatically prompt you for an upgrade.
  • 17.
    Installing a packagewith pip Lets install pandas. Step 1 : Open Command Prompt Step 2: Navigate to the directory C:Python37 Step 3: Enter the command pip install pandas and press Enter key. Now let’s see what happened when I entered this command in my laptop
  • 18.
    Installing Pandas withpip Downloading Pandas Downloading dependencies numpy, python-dateutil,six,pytz Detecting that we are using a older version of pip and prompting for a newer version (optional)
  • 19.
    Installing multiple packageswith pip Sometimes you might need a lot of packages that need to be installed at once. Can we do that with pip ? Yes. Let’s see how we can do that. Before starting the installation we need to create a simple text file called requirements.txt. The name of the file can be anything as you wish , but a good practice is to use “requirements” Here in my example , I’m installing 3 packages with 2 where the version being specified. You can use == operator for an exact version math and >= or <= for a relative version . If you don’t mention the version , then the latest version will be installed
  • 20.
    How to usethe requirements.txt Let’s install packages using requirements.txt Step 1 : Open Command Prompt Step 2: Navigate to the directory C:Python37 Step 3: Enter the command pip install -r “D:SoftwaresPythonrequirements_3.7.txt” Please ensure to mention the correct path of your file in the command above. Now let’s see what happened when I entered this command in my laptop
  • 21.
    Installing multiple packageswith requirements.txt The last line provides vital information about the command that we fired . We fired the command with 3 packages , but pip has managed to install not just the ones we wanted , but also the additional dependencies that are required for the package to work well. Now we will see how offline installation can be done.
  • 22.
    Installing Python Packageswhen you are offline Caution : As I told earlier , offline installation means you have to physically ensure the sequence of dependencies , versions before a particular package can be installed. For our case , let’s install a package on offline mode. In order to install a package offline , you have to download either the wheel file or the source file . Wheel File : .whl format . Compiled binary version of package . Therefore no need to compile it in . Source File: .py format mostly . Has to be compiled in the machine where you install it. Let’s see an example for both.
  • 23.
    Installing from whlfile Step 1 : Download the .whl file for the desired package Step 2: Open Command Prompt Step 3: Navigate to the directory C:Python37 Step 4: Enter the command pip install <Complete path with your wheel file name> Please ensure to mention the correct path of your file in the command above.
  • 24.
    Installing from sourcefile Source files are normally available as zip or tar files . Hence a couple of additional steps. Step 1 : Download the .tar / .zip file for the desired package Step 2: Uncompress the tar file and verify if you have the setup.py Step 3: Open Command Prompt Step 4: Navigate to the directory C:Python37 Step 5: Enter the command python <complete path of the setup.py> --install Note: Because we are executing a .py file ( which is a python script) we are using the command “python” and not “pip”
  • 25.