The power of Python packages and how to install them using pip
Python is a very popular programming language. An aspect of Python that makes it so popular is the wide range of available packages. Packages are pieces of software that can be installed on a computer and imported in scripts. Once a package is installed and imported a programmer can make use of all its contents.

Being able to easily install and use pieces of software developed by others opens up an enormous range of possibilities for a programmer. To illustrate what I am talking about, here are some examples of popular packages and what you can do with them.
- Requests — The requests package makes webscraping possible. Webscraping is gathering data from websites. You can use this package to load the HTML file of a webpage into Python. The requests package also enables programmers to communicate with APIs. An API is a system to send and receive data.
- Matplotlib — The matplotlib package can be used to make graphs. For data scientists data visualizations can be useful both for eploring data as presenting results.
- Pandas — The pandas package offers dataframes. Dataframes can be used to work with data stored in a table format.
Installing Python packages
If by now you are excited to try some packages, you might ask yourself: How can I install packages? Well, here I have a simple tutorial for you.
Step 1 Open the application ‘Command prompt’ on your Windows computer. Or the application ‘Terminal’ on your Apple computer.
Step 2
In the opened application, type the following command and hit enter. In our example we will install the pandas package and so we use the package-name: pandas.
pip install pandasAnd with those 2 steps you are done installing Python.
Importing Python packages and using them
To use the contents of a Python package you first have to import it in your script. This can be done with an import statement. Import statements are typically at the top of a script. This is an example of importing the requests package.
import requestsAmong the contents of the requests package is the get function. If you want to use a something from a package you have to specify it comes from the package. This way Python knows where to find it. You specify it by writing the package name + a dot (.) + the name of the function.
This is how you call the get function from the requests package:
requests.get(url)Troubleshooting problems with pip install
- Are you connected to the Internet? Since you are downloading software from an online repository you will need an Internet connection to use pip install.
- Do you have pip installed? pip is a package installer for Python. It gets automatically installed if you use Python version 3.4 or higher. That is if you use the default settings in the Python installer.
To learn more about the installation and usage of pip visit PyPI’s website. PyPI stands for Python Package Index, it is where all the packages are stored.
Tip for working with packages
To prevent problems with using different packages and package versions you can install the packages for different projects in isolated environments.
Such an isolated environment is called a virtual environment. They are easy to make and use. You can read more about virtual environments in this short article:
Thank you for reading!
You can get full access to all my posts by joining Medium. Your membership fee directly supports me and other writers you read. You’ll also get full access to every story on Medium:





