Notes on PyCharm’s package manager

Notes on PyCharm’s package manager, by Al McDivitt.

Introduction.

When you are working with python you will need to use library packages, to a add functionality to your code, as I have shown in my Notes on PIP Package installer for Python.

PIP is installed by default when you install python on Windows, so you can use it from either a power shell or command prompt (with admin privileges).

However if you are programming in PyCharm, you can do it all right there in the IDE.

Oh no an error!

I tried to run my code in the IDE and I got the red exclamation mark where it says.

“import requests”

The error message tells me what’s wrong and what to do…

No module named ‘requests’

What will I do? Well if you press the Alt key and the Shift key and then press ENTER, the library, in this case “requests”, will be installed for you automatically. But do you really learn anything doing it this way?

Let’s learn another way to manage library’s; where we can add, remove and also find library’s which may be useful to our coding and get documentation about it’s use as well. Sounds like it could be cool. So here goes.

OK, we have a missing Module.

The code is telling you there is no module named “requests”.

The Module can be either a library or package; I know it gets confusing.

I will quote something I read on the internet.

Python Libraries

Actually, this term is often used interchangeably with “Python package” because packages can also contain modules and other packages (sub packages). However, it is often assumed that while a package is a collection of modules, a library is a collection of packages

So, what next?

Select the missing library’s name.

Select the Missing package name. Then right click to open the drop down menu.

Select copy from the drop down menu.

Open Package Manager.

On the File menu, Select View→ Tool Windows→ Python Packages, and click.

Find Package.

Place mouse in the search box, just to the right on the magnifier glass icon.

Hold down the Ctrl Key and the v key and the text you copied should be pasted into the search box.

In this case “requests”

If the package manager finds the package (Library), It will automatically prepare it for installation, including showing you the documentation. Just click Install.

Package installed.

You will see in the bottom left of the IDE a message showing installation success.

Look at that, no more error.

Delete package using Package Manager.

On the File menu, Select View→ Tool Windows→ Python Packages, and click.

Select the package you want to delete, in this case I will use the requests package.

  1. Click the three dots on the left.
  2. Select the Delete Package popup.
  3. Package Uninstalled successfully message will display.
  4. With the package removed the import requests shows red again.

Using Package Manager to look up packages.

Sometimes you see a package in someone’s code, and your not sure what it does. Well, although today the Web is the go-to for information, looking packages up in the package manager can be enlightening.

Searching BeautifulSoup4 brings up this info… and helps your learning.

That’s a wrap

Well, that’s just a quick introduction PyCharm’s package manager … The fast track to get started. You may want, or possibly need to learn more. There is plenty of in depth stuff on the web to further your knowledge.

Hope this quick start is of some help and excites you to go further.

Cheer’s Al

AL McDivitt

Blog – www.iotxplain.com.au/blog/

Web – www.iotxplain.com.au/