28

I have started to use PyCharm IDE, but I was not able to determine how to manage external libraries there. For instance, PyCharm does not see matplotlib. In PyCharm's file manager, I clearly see the list of external libraries and there is no matplotlib. However, I have it installed and I know its location.

How can I add this library to PyCharm environment?

Mogsdad
  • 44,709
  • 21
  • 151
  • 275
freude
  • 3,632
  • 3
  • 32
  • 51

5 Answers5

53

I suggest to use Python virtual environment. It is really easy with PyCharm.

PyCharm > Preferences... > Project Interpreter > Python Interpreters

Click "Create Virtual Environment" and pick your base interpreter.

enter image description here

Click "Install" and install any packages you need. You can also add other repositories if the default ones do not contain required libraries. Another benefit is that you can see which libraries have newer version and can be updated.

enter image description here

kukido
  • 10,431
  • 1
  • 45
  • 52
  • 5
    FYI - For the Windows PyCharm Comm v.2016.2, the menu is a little different. `File->Default Settings...->Project Interpreter` – Eric Fossum Aug 30 '16 at 17:28
  • @kukido Does this install a copy of matplotlib for each project? Suppose I have 5 projects in my workspace, and I add matplotlib for all projects, would this create 5 copies of matplotlib? – bub Feb 09 '19 at 17:33
5

I think one way to solve a problem is to specify your interpreter in PyCharm itself via File -> Settings -> Python Interpreters

There is also a Paths tab in this setting, you need to add path to your matplotlib explicitly there. But for me there is no special path listed there. Here are my paths in this tab:

file://D:/hg_work/vefw_regression/tools/python/DLLs
file://D:/hg_work/vefw_regression/tools/python/Lib
file://D:/hg_work/vefw_regression/tools/python/Lib/lib-tk
file://D:/hg_work/vefw_regression/tools/python
file://D:/hg_work/vefw_regression/tools/python/Lib/site-packages (my matplotlib/numpy and other stuff is here)
file://D:/hg_work/vefw_regression/tools/python/Lib/site-packages/win32
file://D:/hg_work/vefw_regression/tools/python/Lib/site-packages/win32/lib
file://D:/hg_work/vefw_regression/tools/python/Lib/site-packages/pythonwin
file://D:/Users/svecovs/AppData/Roaming/JetBrains/PyCharm Community Edition 3.0.1/helpers/python-skeletons
file://D:/hg_work/vefw_regression/tools/python/Lib/site-packages/core (added by user)

arbulgazar
  • 1,931
  • 1
  • 19
  • 24
  • 1
    When I run this script in command line default python interpreter, everything goes well. I have got problems only by using Pycharm. At the PATH Tab of the PyCharm configuration interface, I have add path to matplotlib, but I still get same error message. – freude Feb 19 '14 at 14:56
  • For me, there wasn't also any paths to any special libraries. – freude Feb 19 '14 at 14:58
  • 1
    PyCharm can have it's own path for python interpreter. For example I have `D:/python/` in my windows `PATH` (command line takes this), but PyCharm is configured to use python on external server: `Python 2.7.3 (D:/hg_work/vefw_regression/tools/python/python.exe)` on mentioned `Python Interpreters` tab – arbulgazar Feb 19 '14 at 15:02
  • 2
    I have found the solution. You were partially right, the problem was related to the choice of the proper python interpreter. I have installed matplotlib for the python version 2.7, but PyCharm was configured for the version 3.0 When I switch it to the version 2.7, everything works fine. – freude Feb 19 '14 at 15:13
  • Note that the paths is not there anymore, you have to go project interpreter - wheel- more- show path for the selected interpreter http://stackoverflow.com/a/24206781/1136458 – lib Dec 10 '14 at 14:12
1

Install matplotlib and then python-tk.Pycharm will function well.It's working for me at Ubuntu 16.04.

sudo apt-get install python-tk

sudo apt-get install python-matplotlib

Community
  • 1
  • 1
Mamuns
  • 11
  • 1
0

For Linux Users here is a solution , firstly write this command in the terminal ,

sudo apt-get install python-matplotlib

Now you're done you will be able to see matplotlib in File>>>settings>>project interpreter. Image

Akash Kandpal
  • 3,126
  • 28
  • 25
0

Solve this problem by choosing system interpretator.

Yunnosch
  • 26,130
  • 9
  • 42
  • 54
ilya
  • 1