Knowledge expands consciousness, and libraries extend the possibilities of programming languages. We will explain how to add them in Python.
We have already discussed how to install Python on various operating systems. If you want to extend the capabilities of the language, use a package manager – this is how libraries and modules are connected. And if you’re wondering how to learn programming in Python and get a job, sign up for the “Python Developer” course.
Manual Installation
This method does not require a traditional package installer like pip
– modules are connected directly from the source. This is convenient when you have multiple versions of Python and need to import modules into different versions. We recommend learning how to do this right away.
Install setuptools
- Download the file from PyPI and extract it to your system.
- Open a terminal session and change the directory to the folder containing the setup file.
- Run the command:
python setup.py install
- Note!
If Python is located outside your system path, it will throw an error saying the command was not found. In that case, specify the path manually. For Windows, it looks like this:c:\python34\python.exe setup.py install
Install Using easy_install
As the name suggests, this method is easy and involves only two clicks. If you have manually installed setuptools
, your computer will already have it, and you can use easy_install
located in the Python Scripts folder.
If you add the Scripts folder to your operating system path, you can use easy installation through the command line without specifying the full path.
Now, do the following:
easy_install package_name
And automatically install any necessary packages. However, it has some limitations:
- It might try to run a package that hasn’t been fully downloaded yet.
easy_install
packages cannot be uninstalled.
Due to these and other reasons, the Python community developed and implemented a program called pip
.
Installing pip
This came with Python 3.4 and is downloaded along with the language, but if you have an earlier version, install pip
manually:
- Go to PyPI and download the
get-pip.py
script. - Then execute the following command:
python get-pip.py
If setuptools
wasn’t previously installed on your computer, it will be installed along with pip
. With its help, any library and files can be added – everything that easy installation can install. But now a different command will be used:
pip install package_name
And to update a package, use:
pip install -U PackageName