How to Install a Library on PyCharm?

3.2/5 - (46 votes)

Problem Formulation: Given a PyCharm project. How to install a library in your project within a virtual environment or globally?

Solution that (almost) always works:

  • Open File > Settings > Project from the PyCharm menu.
  • Select your current project.
  • Click the Python Interpreter tab within your project tab.
  • Click the small + symbol to add a new library to the project.
  • Now type in the library to be installed, for example Pandas, and click Install Package.
  • Wait for the installation to terminate and close all popup windows.

Here’s the installation process as a short animated video:

How to Install a Library on PyCharm?

In some PyCharm versions, the installation steps will be slightly different. If this is you, here are the steps that are likely to work for you to install a library in PyCharm:

  1. Open PyCharm and select the project where you want to add the library.
  2. Go to "File" > "Settings" (On MacOS, it’s "PyCharm" > "Preferences"). This will open the Settings/Preferences dialog box.
  3. In the Settings/Preferences dialog box, go to "Project: <Your_Project_Name>" > "Project Interpreter".
  4. Here, you will see a list of packages already installed in your current project’s environment.
  5. To add a new package, click on the "+" button at the bottom of the package list.
  6. In the "Available Packages" dialog box that opens, you can search for the library you want to install.
  7. After finding the desired library, select it and click on the "Install Package" button at the bottom of the dialog box.
  8. PyCharm will then install the package in your project’s environment.
  9. Once installation is complete, you should see the new library in the list of packages in the Project Interpreter settings.

Please note that PyCharm will use the interpreter which is selected for the project. So, the installed library will be added to the interpreter used for the project, and it may not be available to other projects or other Python interpreters on your computer.

Also, the package management is done using pip, so if pip is not installed or not working in your environment, you may face issues while installing the libraries.

Check out the following Finxter guide on installing pip:

How to Install PIP in Python?

Programmer Humor

It’s hard to train deep learning algorithms when most of the positive feedback they get is sarcastic. — from xkcd