Python Libraries
Python Libraries
Python Libraries
Normally, a library is a collection of books or is a room or place where many books are
stored to be used later. Similarly, in the programming world, a library is a collection of
precompiled codes that can be used later on in a program for some specific well-defined
operations. Other than pre-compiled codes, a library may contain documentation, configuration
data, message templates, classes, and values, etc.
A Python library is a collection of related modules. It contains bundles of code that can be
used repeatedly in different programs. It makes Python Programming simpler and convenient for
the programmer. As we don’t need to write the same code again and again for different programs.
Python libraries play a very vital role in fields of Machine Learning, Data Science, Data
Visualization, etc.
Python standard library
The Python Standard Library contains the exact syntax, semantics, and tokens of Python. It
contains built-in modules that provide access to basic system functionality like I/O and some other
core modules. Most of the Python Libraries are written in the C programming language. The Python
standard library consists of more than 200 core modules. All these work together to make Python a
high-level programming language. Python Standard Library plays a very important role. Without it,
the programmers can’t have access to the functionalities of Python. But other than this, there are
several other libraries in Python that make a programmer’s life easier. Let’s have a look at some of
the commonly used libraries:
1.TensorFlow: This library was developed by Google in collaboration with the Brain Team. It is
an open-source library used for high-level computations. It is also used in machine learning and deep
learning algorithms. It contains a large number of tensor operations. Researchers also use this Python
library to solve complex computations in Mathematics and Physics.
2.Matplotlib: This library is responsible for plotting numerical data. And that’s why it is used in
data analysis. It is also an open-source library and plots high-defined figures like pie charts,
histograms, scatterplots, graphs, etc.
3.Pandas: Pandas are an important library for data scientists. It is an open-source machine learning
library that provides flexible high-level data structures and a variety of analysis tools. It eases data
analysis, data manipulation, and cleaning of data. Pandas support operations like Sorting, Re-indexing,
Iteration, Concatenation, Conversion of data, Visualizations, Aggregations, etc.
4. Numpy: The name “Numpy” stands for “Numerical Python”. It is the commonly used library. It is a
popular machine learning library that supports large matrices and multi-dimensional data. It consists of
in-built mathematical functions for easy computations. Even libraries like TensorFlow use Numpy
internally to perform several operations on tensors. Array Interface is one of the key features of this
library.
5.SciPy: The name “SciPy” stands for “Scientific Python”. It is an open-source library used for high-
level scientific computations. This library is built over an extension of Numpy. It works with Numpy to
handle complex computations. While Numpy allows sorting and indexing of array data, the numerical
data code is stored in SciPy. It is also widely used by application developers and engineers.
6.Scrapy: It is an open-source library that is used for extracting data from websites. It provides very
fast web crawling and high-level screen scraping. It can also be used for data mining and automated
testing of data.
7.Scikit-learn: It is a famous Python library to work with complex data. Scikit-learn is an open-source
library that supports machine learning. It supports variously supervised and unsupervised algorithms like
linear regression, classification, clustering, etc. This library works in association with Numpy and SciPy.
8.PyGame: This library provides an easy interface to the Standard Directmedia Library (SDL) platform-
independent graphics, audio, and input libraries. It is used for developing video games using computer
graphics and audio libraries along with Python programming language.
9.PyTorch: PyTorch is the largest machine learning library that optimizes tensor computations. It has
rich APIs to perform tensor computations with strong GPU acceleration. It also helps to solve application
issues related to neural networks.
10.PyBrain: The name “PyBrain” stands for Python Based Reinforcement Learning, Artificial
Intelligence, and Neural Networks library. It is an open-source library built for beginners in the field of
Machine Learning. It provides fast and easy-to-use algorithms for machine learning tasks. It is so flexible
and easily understandable and that’s why is really helpful for developers that are new in research fields.
Installing Python Modules
As a popular open source development project, Python has an active supporting community of
contributors and users that also make their software available for other Python developers to use
under open source license terms.
This allows Python users to share and collaborate effectively, benefiting from the solutions
others have already created to common (and sometimes even rare!) problems, as well as potentially
contributing their own solutions to the common pool.
Key terms
● pip is the preferred installer program. Starting with Python 3.4, it is included by default with the Python
binary installers.
● A virtual environment is a semi-isolated Python environment that allows packages to be installed for
3.3. Starting with Python 3.4, it defaults to installing pip into all created virtual environments.
● virtualenv is a third party alternative (and predecessor) to venv. It allows virtual environments to be
used on versions of Python prior to 3.4, which either don’t provide venv at all, or aren’t able to
automatically install pip into created environments.
● The Python Package Index is a public repository of open source licensed packages made available for
the maintenance and evolution of the standard packaging tools and the associated metadata and file
format standards. They maintain a variety of tools, documentation, and issue trackers on both GitHub
and Bitbucket.
Basic usage
The standard packaging tools are all designed to be used from the command line.
The following command will install the latest version of a module and its dependencies from the Python
Package Index:
it’s also possible to specify an exact or minimum version directly on the command line. When using
comparator operators such as >, < or some other special character which get interpreted by shell, the
package name and the version should be enclosed within double quotes:
Normally, if a suitable module is already installed, attempting to install it again will have no effect.
Upgrading existing modules must be requested explicitly: