Python offers endless different packages that enables you to utilize different features and functionality. If you need to automate in Excel, for example, you can find many different packages enabling you to write a program to work in Excel. Also, if you need to perform GUI automation via Python, work in different browsers, analyze data or images, etc. The options are (almost) infinite. Therefore, it is important for you to know how to install packages to your Python engine and make use of them. This article will guide you on how to install Python packages properly and make use of them in your projects.
The article is based on you having installed Python as explained in this article.
Install Packages via CMD
You can easily install packages via the CMD using what is called pip. You should already have pip installed if the installation guide was followed, meaning that it is very easy to install additional packages via the CMD. Start by opening your cmd and then use the "cd" command to navigate to the folder of where you have Python installed:
Now, you are ready to install a package. Which package you need depends on what you wish to do with Python. At the end of the article, we will list the packages that we recommend you use. Here is an example of installing a package. You simply have to write: "pip install X" with X being the name of your package, for example, "pip install xlwings":
The installation is now completed and you can make use of the given package in your Python projects. Simple as that!
Install Packages via PyCharm
One of the cool things about PyCharm is that you can actually do exactly the same as shown in the CMD in PyCharm. So while working on your projects in PyCharm, you can install packages directly in the terminal of PyCharm. What you need to write is exactly the same. Here is an example. First, click to open the terminal in PyCharm:
Now, execute the two commands exactly the same way as in the CMD:
To make use of your packages, simply import your package and write your code. For example:
List of Useful Packages
As mentioned, there are a lot of different packages to use in Python for different purposes. It is up to you to find the ones that you prefer. Below is a list of packages worth checking out under the different areas:
For GUI automation
- pyautogui (enables you to automate based on coordinates and images)
- pywinauto (enables you to automate based on the programming layer of applications)
For Excel automation
- pandas
- xlrd
- xlwings
- openpyxl
For PDF automation
- PyPDF2
- pdfminer2
For browser automation
- Selenium
To compile your Python project into .exe file
- pyinstaller
Comments
0 comments
Please sign in to leave a comment.