7

I have Ubuntu 20.04.

python3 --version this command showed that Python's version is 3.8.10.

I haven't changed (added/deleted) any modules/folders that belong to Python, it's in the default configuration.

I wanted to know whether all the modules in the standard library of Python is pre-installed in my computer. If not all modules of the standard library are installed, what's the reason for it (is it that only libraries that require for the Ubuntu to run are installed and rest are ignored)?


Edit:

I changed my question: Do I have everything that I get when I install python by Downloading it from python.org, pre-installed?

3 Answers 3

7

Python has a "standard library", which is included by default in Ubuntu.

The package name is libpython3-stdlib.

The Python standard library includes a number of modules, which are documented here.

6
  • I'm new to python, so I exactly don't know the differences between Libraries and Modules. I want to use modules (I dont what they're exactly called) like 'NUMPY', 'SYMPY', etc. I thought each one of these is a Library. So, in this site docs.python.org/3/library/index.html I could see a list which I thought that each of them in that list is a Standard library. But when I used 'help' command on Python's console to know the installed modules, I felt that I have much lesser than what is there on this webpage.
    – user1574528
    Mar 10, 2022 at 13:10
  • My changed question: Do I have everything that I get when I install python by Downloading it from python.org, pre-installed?
    – user1574528
    Mar 10, 2022 at 13:23
  • 2
    To my knowledge, all modules in the standard library should be included. Mar 10, 2022 at 13:30
  • Note though that some of the entries in the documentation page are direct links to submodules, which do not show up separately in the help modules output. For example, all the xml.* stuff just shows up as a single xml module, and os.path is not listed because it’s part of os. Mar 10, 2022 at 21:14
  • 1
    @ByteManager People are often not very precise with the terminology, but I think the best word for things like Numpy and sympy would be packages. Basically, a Python package is a collection of Python modules which is distributed separately from the Python interpreter itself, most often through PyPI. The Python standard library, on the other hand, is a collection of Python modules which is usually distributed along with the Python interpreter itself. Hopefully that helps you make sense of all this.
    – David Z
    Mar 11, 2022 at 6:56
4

It has been shown numerous times that it is a bad idea to try to update or remove the python that comes preinstalled with a Ubuntu; it is a task that requires an advanced user.
e.g. major portions of apt and apt-get depend on python.

Based on reading many postings on askubuntu; just don't, for your own peace of mind.

$ sudo apt install python3-pip
...
$ python3 -m pip freeze >requirements.txt
...

With pip you can install new python things in a controlled manner, generate a list of installed things and by that copy the setup to / from another 'python3'.

$ python3 -m pip help
... 
python3 -m pip install [options] -r  [package-index-options] ...
...

$ python3 -m pip install -r requirements.txt

... where "install -r requirements.txt" will take the file produced above and try to pull in (install) those packages.

1
  • Projects such as pipenv, virtualenv, poetry, and others are helpful in that they allow you to have virtual environments that have dependencies that don't pollute the system and user package directories with possibly-conflicting versions. Just try to avoid ending up like this: xkcd.com/1987 Mar 11, 2022 at 2:47
0

Most of the standard library is included when you install the Debian/Ubuntu python3 package. However some parts are split off into separate packages or are excluded completely.

The Debian python policy gives some examples of excluded or separately packages modules, but I'm not sure there is a comprehensive list anywhere.

You must log in to answer this question.