Are all libraries available in each IDE

Hi,

I was just reading about libraries in Python. At present I have started to learn Python using Spyder.
I have a doubt here, are all the libraries available in each of the IDE.

Just as an example, Numpy is a library, this is available in Spyder. Will it be available in each IDE available for Python. Numpy is used just as an example. Can anyone please help me clear my doubt. Thanks.

Python is a software distribution that comes with a standard library of utilities.
Modules written by other people around the world are usually shared through module repositories (pypi, python package index). The standard python library may include a “pip” program which is used to obtain and install modules from pypi repository. In various operating systems (e.g. debian/ubuntu) python pip package may need installing separately (apt install python-pip).
Afterwards you may use pip to install 3rd party packages, e.g. “pip install requests” would download, build and install a “requests” library. And this is what IDEs are doing under the hood. There are similar tools like anaconda, etc. which serve the same purpose, but the principle is the same.

Note: using pip will try to install the libraries in a system locations which might need administrative rights.
For installing in a project or a user home directory we use a concept of virtual environment.
Standard python library has a “venv” module that enables you to create such an environment (within your home directory, or per project).

IDEs do it under the hood, and usually you are supposed to choose/create you environment in a project configuration inside an IDE.

So in essence, what happens is:
a) Creating a virtual environment: python -m venv .venv
b) Entering the environment: source .venv/bin/activate
c) Installing packages (in sourced env): pip install somelibrary

1 Like

Hi @pymc I can not thank you enough. I am re-reading your post to understand it.
Thanks for such a detailed reply, will help me a lot.

Have a nice day ahead. :slight_smile:

Hi @pymc, one question, I forgot to asked earlier.
Is it possible that library retires with time. Just as an example, Matplotlib was available till year 2019 however post 2019 this library was retired.

Does this happen, if yes, how do we change our code in such scenario.

What do you mean by “retired”? That the versions change, or that they are no longer available?
Simply - they do not “retire”.

I just installed matplotlib right now using pip:
Successfully installed cycler-0.10.0 kiwisolver-1.1.0 matplotlib-3.1.3 numpy-1.18.1 pyparsing-2.4.6 python-dateutil-2.8.1 six-1.14.0

Note: pip can also be given an “–upgrade” option, i.e.: “pip install --upgrade matplotlib”, which would install matplotlib if you don’t have it, upgrade it to a newer version (if an upgrade is available), or do nothing (in case it’s already installed and no new versions are available yet).

1 Like

Hi @pymc, sorry for confusion, my meaning was, these are no longer available.
For instance Numpy was available till 2019 post 2019 it was not available for working.

It is used in older projects but now Python does not support this library.
Just wanted to know if such scenario happens.

Basically - when you learn python - start with running it in a terminal (just the interpreter alone) and poking around.
There’s nothing magical in IDEs. They just run python and python tools under the hood.
You edit some file (e.g. yourscript.py), click some “run” button, and your IDEs does “python yourscript.py”.
You click “install a package”, choose a package from a list, and it runs “pip install the_chosen_package”.
There’s no magic. So note - if you start with IDE - it will take much longer to understand (get accustomed to) the basic principles. And if you never learn doing it by hand, then you end up thinking that “my IDE doesn’t have a button for so-and-so, thus so-and-so is impossible”. Run python in a terminal. Run pip in a terminal.
On Windows these are probably python.exe and pip.exe, but I don’t know.
They are just ordinary, regular executables (binary programs).

1 Like

Hi @pymc, thanks for guidance, sure, I will do it. Have a nice day ahead. :slight_smile:
It is just that our training has started using Spyder IDE, all my questions are based on IDE use.

Hi Sachin,

The short answer is “Yes”. The long answer is “Maybe”. It depends on how
and where you install the packages, and it depends on whether each IDE
is using the same version of Python or not.

If you only use one version of Python, and want to pick and choose a
different IDE whenever you feel like changing, it is probably best to
install to either the system wide package location (for experts only) or
your user package location. Then every IDE should be able to see the
packages.

If your IDE offers its own private package location, then other IDEs
will not be able to see those packages. This does not matter for people
who use only a single IDE and nothing else.

This is my recommendation: if you are only using a single version of
Python, and don’t need to install multiple versions of the same
packages, then just install into your user package location.

B’s answer about “virtual environments” was, I think, incorrect. None of
the IDEs I have tried have forced you to use virtual environments. Some
IDEs like PyCharm offer virtual environments, but I don’t think they are
compulsory.

Some, like Spyder, are themselves a Python package, so you can install it
inside a virtual environment if you want, or not, as you choose.

The point of using a virtual environment is to isolate packages from the
rest of your system, so that if you install numpy in one virtual
environment, it won’t be available anywhere else.

Personally, I find that the opposite behaviour to what I want. I am sure
that virtual enviroments are a fantastic feature for those who need to
isolate their installations or need to have twenty different versions of
numpy installed, but if you don’t need or want that, it is (in my
opinion) less confusing and simpler to avoid virtual environments.

2 Likes

Hi @steven.daprano, thanks a lot for such a detailed help.
Please give me some time to read and understand.

Have a nice day ahead. :slight_smile:

Numpy is still available and absolutely is supported by Python now. What
makes you think it is not?

It can happen that a third-party library will stop being maintained.
It might even be removed from the internet (but probably not). But
you will still have archived copies of that library. The library owner
cannot reach into your computer and delete the copy you have already
downloaded. The existing copies will keep working, they just stop
getting updates.

On the other hand, using an API to third-party software as a service is
very risky, if the service is removed, then it will just stop working.

What happens when a library no longer gets updates? You have at least
four choices:

  • replace it with a new library;
  • use the old, unmaintained, version;
  • unofficially and privately maintain the library yourself;
  • stop using your project.

The choice is yours.

1 Like

This is what I was not sure. Thanks for the help @steven.daprano , have a nice day ahead. NumPy was just as an example of library. :slight_smile: