Hello Folks....!!!
Today I will give you the introduction about some terms which will be
commonly used hereafter.
What are modules ?
Modules are nothing but just Python functions coded and stored as a file with
.py extension. They can be imported and utilized in any programs/project we
do. They are simply executable python files. For example, If you are designing
a calculator, then its functionalities are adding, subtracting, multiplying,
dividing and finding modulo for given inputs. Thus each function can be
written in separate .py files which makes them a module.
What are packages then ?
Packages are collection of modules. They should have a special file called
__init__.py. As we all know writing this way corresponds to constructor,
whenever the package is imported, this special file is executed for loading
the requirements. The packages are also treated as classes you can import them
(like inheriting) and use the functionalities in it. Consider the same example
said above. If the arithmetic operations are functionalities then the
calculator is the package. Once you pack all the modules within it, the
calculator can be imported in any required placed and utilized instead of
writing the code from scratch. There are several built-in packages which you
can use. You can also write your own package and use it.
How to install these packages and modules ?
There two ways to install these packages. pip install and
conda install.
pip install : It is a recursive acronym which stands for Pip Installs Packages or Pip
Installs Python. pip is used for package management in python. The packages
that are present in PyPI (Python Package Index) can be easily installed
using pip command.
While installing various packages there may be some dependencies, ie., one
package may need another to be pre installed. For handling such things, pip
will use a recursive loop to check for the dependencies. This will sometimes
lead to breaking the environment if the versions of the previously checked
package is not compatible with the later one.
It requires a compiler and runs on virtual environment. It can be used to
install Python packages only. There are around 1,50,000 packages available on
PyPI and could be installed using pip command. For installing packages using
pip, follow the steps below :
-
Open Anaconda command prompt.
-
On the black screen, after the path appears, type pip install package_name. For
example, if I wish to install the calculator package, then I should write
pip install calculator.
-
Wait until installation finishes. Once done you can import and use the in
.py or .ipynb files.
conda install : It is a cross platform
package and environment manager. Unlike pip it allows user to install C, C++
libraries or packages of R language also. It is not limited to Python
software/packages. The packages that are available in Anaconda repository and
Anaconda clouds can be installed using conda install command.
The dependency check is done by a Satisfiability (SAT) solver here. This takes
extra time to verify the dependencies and their versions but broken
environments are prevented. As this allows installation any language libraries
while doing data analytics project conda install is preferred as one may use
various kinds of tools in the analytical process.
To install packages using conda command, follow the same steps as given for
pip, but in the place of pip just write conda. For example
conda install package_name.
If the package is already installed, then both return a message stating that
requirement already satisfied.
Comments
Post a Comment