It depends on the Ubuntu version and the IDE you are using.
Ubuntu 15 and older come with Python 2.7 and Ubuntu 16.04 comes with both Python 2.7 and 3.5.
Now based on the IDE you are using there are several ways to do this. Let`s say you only installed Spyder from Ubuntu app store or installed Jupyter. In other words you do not have a distribution like Anaconda or Enthought which install their own Python versions. This is important to pay attention to because once you are trying to install a package/library, you need to know which Python it is being installed to.
Now assuming you just have an IDE that is connected to Ubuntu`s default Python versions, you can use the terminal to install your packages:
For python 2.7 use
pip install libraryname
For python 3.5 use
pip3 install libraryname
Sometimes, for reasons that I don`t know, during the package installation process, Linux blocks access to the Python so try these as well:
sudo apt install python-libraryname
and for Python 3.5
sudo apt install python3-libraryname
These have helped me to install all the libraries that I need.
Now, if you are using a distribution like Aanaconda or Enthought, there is a good chance that the libraries that you are installing are not going to be added to the libraries that those distributions use. In order to install the libraries for these distributions, once you run the distribution, go to the ipython console and write
!pip install libraryname
In case of Enthought, it has it`s own Package Manager where it has most of the libraries you need and you can install them there without using pip or anything else.