0% found this document useful (0 votes)
9 views10 pages

APP Lab Expt - 1

The document provides detailed instructions for downloading and installing Python 3 and its package manager pip3 on various operating systems including Linux, Windows, and MacOS. It includes commands for installation, checking versions, and managing packages, as well as guidance on using pip3 within virtual environments and with Anaconda. Additionally, it introduces the Active State platform for Python package management and provides examples of using Jupyter Notebook.

Uploaded by

prabhakarele8
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views10 pages

APP Lab Expt - 1

The document provides detailed instructions for downloading and installing Python 3 and its package manager pip3 on various operating systems including Linux, Windows, and MacOS. It includes commands for installation, checking versions, and managing packages, as well as guidance on using pip3 within virtual environments and with Anaconda. Additionally, it introduces the Active State platform for Python package management and provides examples of using Jupyter Notebook.

Uploaded by

prabhakarele8
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

1.

Downloading and Installing Python and Modules

a) Python 3 on Linux Follow the instructions given in the URL

To see which version of Python 3 you have installed, open a command prompt and run

$ python3 --version

If you are using Ubuntu 16.10 or newer, then you can easily install Python 3.6 with the following commands:

$ sudo apt-get update


$ sudo apt-get install python3.6

Python, we recommend using the deadsnakes PPA to install Python 3.8:

$ sudo apt-get install software-properties-common


$ sudo add-apt-repository ppa:deadsnakes/ppa
$ sudo apt-get update
$ sudo apt-get install python3.8

If you are using other Linux distribution, chances are you already have Python 3 pre-installed as well. If not,
dnf:

$ sudo dnf install python3

Note that if the version of the python3 package is not recent enough for you, there may be ways of installing
more recent versions as well, depending on you distribution. For example installing the python3.9 package on
Fedora 32 to get Python 3.9. If you are a Fedora user, you might want to read about multiple Python versions
available in Fedora.

Working with Python 3


At this point, you may have system Python 2.7 available as well.

$ python

This might launch the Python 2 interpreter.

$ python3

This will always launch the Python 3 interpreter.

Example:

gedit add, py
a=50
b=20
print ( a+b )
Save the program
go to save file

python add.py
70

OR

$gedit add.py
a= int (input nter a
b= int ( input ( enter b"))
C=a+b
print ( c)

save the program- go to terminal


python add. Py

b) Python 3 on Windows Follow the instructions given in the URL

https://docs.python.org/3/using/windows.html

(Please remember that Windows installation of Python is harder!)


INSTALLATION STEPS

Four Python 3.11 installers are available for download - two each for the 32-bit and 64-bit versions of the
interpreter. The web installer is a small initial download, and it will automatically download the required
components as necessary. The offline installer includes the components necessary for a default installation and
only requires an internet connection for optional features. See Installing Without Downloading for other ways
to avoid downloading during installation.

After starting the installer, one of two options may be selected:


You will not need to be an administrator (unless a system update for the C Runtime Library is required
or you install the Python Launcher for Windows for all users)
Python will be installed into your user directory
The Python Launcher for Windows will be installed according to the option at the bottom of the first
page
The standard library, test suite, launcher and pip will be installed
If selected, the install directory will be added to your PATH
Shortcuts will only be visible for the current user

other options or post-install actions. To install debugging symbols or binaries, you will need to use this option.

To perform an all-

You may be required to provide administrative credentials or approval


Python will be installed into the Program Files directory
The Python Launcher for Windows will be installed into the Windows directory
Optional features may be selected during installation
The standard library can be pre-compiled to bytecode
If selected, the install directory will be added to the system PATH
Shortcuts are available for all users
C) pip3 on Windows and Linux Install the Python package installer by following the
instructions given in the URL https://www.activestate.com/resources/quick-reads/how-to-
install-and-use-pip3/

Install Pip3
pip3 is the official package manager and pip command for Python 3. It enables the installation and
management of third party software packages with features and functionality not found in the Python standard
library. Pip3 installs packages from PyPI (Python Package Index).

Installation Prerequisites

Check if pip3 is already installed by entering the following command in a terminal or command line:

pip3 v

Output should be similar to:

Usage:

C:\Python38\python.exe -m pip <command> [options]

Commands:

install Install packages.

download Download packages.

uninstall Uninstall packages.

freeze Output installed packages in requirements format.

list List installed packages.

show Show information about installed packages.

...

...

You can also check to see which version of pip3 is installed by entering:

pip3 --version
Output should be similar to:
pip 20.0.2 from C:\Python38\lib\site-packages\pip (python 3.8)

Confirm which version of Python (if any) is installed on your computer by entering:
python --version

Output should be similar to:


Python 3.8.2

Pip3 Installation
Python 3.4+ in most operating systems includes pip3 by default. If your python version is less than 3.4, then
you should upgrade your Python version which will automatically install pip3.

For example, you can install the latest version of Python from ActiveState (Python 3.9), which includes pip3.

Pip3 Upgrade

In operating system environments that already have Python 3 and pip3 installations, you can upgrade pip3, by
entering:

python -m pip3 install --upgrade pip


Pip3 Downgrade

You can downgrade to a previous version of pip3, in case a newer version is causing unexpected compatibility
errors. For example, to downgrade to pip3 v19.0 run the following command:

python -m pip3 install pip==19.0

Pip3 Virtualenv and Venv

When pip3 is used in a virtual environment, it will generally install packages in a path similar to:

<virtualenv_name>/lib/<python_verion>/site-packages

Pip3 Usage
To install a Python package, enter:

Pip3 install <package_name>

Caution:

Linux and MacOS have system Python, that you should leave alone if possible. System Python is configured to
help the operating system work as intended.

Install pip3 Ubuntu and Debian Linux


Ubuntu 18.04 has both Python 2 and Python 3 installed by default, and hence has two pip variants for each

Ubuntu 20.4 has only Python 3, but still requires a separate python-pip 3 installation.

Procedure for installing pip3 on Ubuntu and Debian Linux:

Enter the following command to update Linux:

sudo apt update

Enter the following command to install pip3:

sudo apt install python3-pip

The above command will also install all pip3 dependencies.

To find the location where pip3 installs packages in Ubuntu Linux, enter:

which pip3

Output should be similar to:

/usr/bin/pip3

Install pip3 Windows

To install or upgrade pip3 in a Windows environment that already has Python 3 installed:

Download the latest version of get-pip.py from

<https://bootstrap.pypa.io/>

You can also use the curl command to download get-pip.py:

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

CD into the directory where get-pip.py was downloaded to, and enter the following command to install pip3
and its dependencies:

python3 get-pip.py

You can verify that pip3 is installed by navigating to the default pip3 installation directory, eg.
C:\python38\scripts\, and enter:

pip3 --version

Add Pip3 to Windows Environment Variables


A common problem with running Python tools such as pip3 in Windows, is not having it in the environment
path so that you can access it from anywhere. In most cases, you can navigate to the
default <python_dir>/scripts directory in which the tool is installed in order to run it.
To run pip3 from any location, you need to add the directory in which it is installed in, as a System PATH
environment variable:
1. Open the Control Panel and navigate to System.
2. Click on Advanced system settings in the upper left panel.
3. Click on Environment Variables.
4. Under System Variables, scroll down then double-click the PATH variable.
5. Click New, and add the directory where pip3 is installed,
e.g.C:\Python38\Scripts , and select OK.

Figure 1: Environment Variables: Directory where pip3 is installed:

Install Pip3 MacOS

To install pip3 in a MacOS environment that already has Python 3 installed, enter:

sudo apt install python3-pip

To install pip3 using the Homebrew package manager (if it is installed), enter:

brew install pip3

You can also install pip3 using get-pip.py:


Download the latest version of get-pip.py from https://bootstrap.pypa.io/.
CD into the download directory, and enter the following command:

sudo python3 get-pip.py

get-pip.py will install pip3 for the python version which runs the script.

Pip3 and Conda

Pip3 has limited use in the Conda environment compared to other operating system environments.
Conda has many of the features found in pip3, but is otherwise a completely separate tool. It installs python
modules and packages from the Anaconda Repository. Only after Conda has been used to install as many
packages as possible in a project, should pip3 be used to install any remaining software.
It depends on whether you are familiar with pip3 and Conda, and with how package installations interact
between the two methods. If you are relatively new to Conda and Python, then only use Conda to install
packages in Conda environments. Otherwise pip3 can be used to install packages not found in the Anaconda
Repository. Extra care needs to be taken with pip3 dependencies so that they do not conflict with Conda
packages and dependencies.
If Python 3 and pip3 are installed outside of the Conda environment, then you can run pip3 from an Anaconda
prompt just as you would from a Linux or Windows terminal or command line.
d) Installing numpy and scipy You can install any python3 package using the command
pip3 install

$ py -m pip version
$ py -m pip initall numpy
$ py -m pip install -- upgrade pip
$ py -m pip Version
$ py -m pip install pandas
$ py -m pip install matplotlib
go to start -> cmd -> command prompt will be opened
$ python -- Version
$ py -m pip -- Version
-m pip install scypy
$ py
>>> from scipy import constants
>>> print (constants. pi)
3.1415926535989793
>>> print (constants. kibi)
Output: 1094

e) Installing jupyterlab Install from pip using the command pip install jupyterlab

Anaconda installation :-
1) Go to chrome type anaconda
2) Open official website www.anaconda.com
3) go to pricing check pricing, check its free or not
4) Go to learn more -> toolkit download

Anaconda installers
Windows Macos Linux
64Bit 32 bit 64bit 32bit 64Bit 32 bit

-> Download 64 bit in windows

5) Open Xefile -> I agree Next (all users)


6) Next -> check box (2)
->Next - > Next finish.
Anaconda installation for Linux

1) go to start -> type Anaconda -> You will get all


2) select anaconda navigator (anaconda 3)

3) go to start-> type Anaconda - > go to anaconda


Prompt ->
$ conda info
4 jupyter notebook
click on desktop -> new folder -> rename
->check on folder ->go to new > python3->

Extra care needs to be taken with pip3 dependencies so that they do not conflict with conda packages and
dependencies.

If python 3 and pips are installed outside of the Conda environment, then you can run pip 3 from an Anaconda
prompt just as you would from a Linux or Windows terminal or command Line

If python 3 and pip3 are installed outside of the Conda Environment, then you can run pip3ffrom Anaconda
Prompt just as you would from a Linux or Windows terminal or command Line.

A modern solution to python package management Try Active State in platform

The Active state platform is a cloud- based build tool for python.
It provides build automation and vulnerability remediation for:
o python language cores, including python 2.7 and python 3.5 +
o python packages and their dependencies, including:
o Transitive dependences (i.e. .., dependencies of dependencies)
o Linked c and fortran libraries, so you can build data science packages
o Operating system- level dependencies for Windows, Linux and MacOs.
o Shared dependences (i.e Open SSL)
Find, fix and automatically rebuild a secure version of Python package. like Django and environments in
minutes.
Python package Management In Action.
Get a hands -on appreciation for how the Active state Platform can help you manage your dependencies for
python environments.
Just run the following command to install python 3.9 and our package manager, the state
Tool;
Windows
powerchell - Command "& $ ([scriptblock]:: Create ((New-object Net. Webclient). Downloadsting (" https : //
platform.activestate.com(di/cli/install .ps ))) active.default Activestate-babs/python-3.9 Beta"

Linux:
sh<(curl - qhttps:// platform.activestate.com/di/cli/install.sh) --active-default Activestate - habs/python -
3.9Beta.
Now you can run state install <packagename>.

Jupyter notebook
Ex->
1) In [1] : 3*6
Out [1]: 18
2) In [2] : 6 - 3
Out [2]: 3
3) In [3]: 10|2
out [3]: 5.0
4) In [4] : a=5
a*a*a
out[4]= 125

You might also like