In this article, I will explain the different methods that can be used to list all the Installed Python modules in Linux. If you are a Python Programmer or Developer then you probably know about the importance of Python modules in your Program. Every python program requires to import few of the important modules to implement its predefined functionality in the program.
Hence it is very important to install all the required python modules first before even importing it in your programs. Many times we are not aware of how to check all the installed python modules so that we will know which modules to install and which are not. I am going to show you exactly how you can check this by using 2 very easy methods.
How to List All the Installed Python Modules in Linux
Also Read: Python3: ModuleNotFoundError: No module named “prettytable” in Linux
There are basically two different methods through which you can check all the installed python modules in your Server. We are going to look into both the methods in detail with the help of examples.
Method 1: Using pip3.6 Tool
In this method you would need pip3.6
tool to be installed in your Server. PIP is known as Python Package Installer. It is used for installing python packages and modules. You can check more about PIP on Official Documentation. If it is not installed then you can use yum install python3-pip -y
command to install in your RHEL/CentOS
Based Servers and sudo apt-get install python3-pip
command to install on Debian/Ubuntu
Based Servers. You can find more information about pip3.6 installation on How to Install PIP3 Utility on Linux(RHEL/CentOS 7/8) article.
[root@localhost ~]# pip3.6 freeze certifi==2020.6.20 chardet==3.0.4 idna==2.10 Mako==1.1.3 MarkupSafe==1.1.1 prettytable==1.0.1 requests==2.24.0 urllib3==1.25.11 wcwidth==0.2.5
Method 2: Using python3.6 Tool
Another method that you can use is through python3.6
utility. You can go to the python prompt by running python3.6
command as you can see below. Then you can run help("modules")
to list all the installed python modules. If you do not have python3 installed then you can use yum install python3 -y
command to install on RHEL/CentOS
Based Servers and sudo apt-get install python3.6
command to install on Debian/Ubuntu
Based Servers. Also you can check How to Install Python3 on CentOS 7 article to know more about the installation steps.
[root@localhost ~]# python3.6 Python 3.6.8 (default, Apr 2 2020, 13:34:55) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> help("modules") Please wait a moment while I gather a list of all available modules... DailyReport _weakrefset hmac runpy DailyReport_OLD abc html sched StatsAnalyzer aifc http secrets __future__ antigravity idna select _ast argparse imaplib selectors _asyncio array imghdr setuptools _bisect ast imp shelve _blake2 asynchat importlib shlex _bootlocale asyncio inspect shutil _bz2 asyncore io signal _codecs atexit ipaddress site _codecs_cn audioop itertools smtpd _codecs_hk base64 json smtplib _codecs_iso2022 bdb keyword sndhdr _codecs_jp binascii lib2to3 socket _codecs_kr binhex linecache socketserver _codecs_tw bisect locale spwd _collections builtins logging sqlite3 _collections_abc bz2 lzma sre_compile _compat_pickle cProfile macpath sre_constants _compression calendar macurl2path sre_parse _crypt certifi mailbox ssl _csv cgi mailcap stat _ctypes cgitb mako statistics _curses chardet markupsafe string _curses_panel chunk marshal stringprep _datetime cmath math struct _dbm cmd mimetypes subprocess _decimal code mmap sunau _dummy_thread codecs modulefinder symbol _elementtree codeop multiprocessing symtable _functools collections netrc sys _gdbm colorsys nis sysconfig _hashlib compileall nntplib syslog _heapq concurrent ntpath tabnanny _imp configparser nturl2path tarfile _io contextlib numbers telnetlib _json copy opcode tempfile _locale copyreg operator termios _lsprof crypt optparse test _lzma csv os textwrap _markupbase ctypes ossaudiodev this _md5 curses parser threading _multibytecodec datetime pathlib time _multiprocessing dbm pdb timeit _opcode decimal pickle token _operator difflib pickletools tokenize _osx_support dis pip trace _pickle distutils pipes traceback _posixsubprocess doctest pkg_resources tracemalloc _pydecimal dummy_threading pkgutil tty _pyio easy_install platform types _random email plistlib typing _sha1 encodings poplib unicodedata _sha256 ensurepip posix unittest _sha3 enum posixpath urllib _sha512 errno pprint urllib3 _signal faulthandler prettytable uu _sitebuiltins fcntl profile uuid _socket filecmp pstats venv _sqlite3 fileinput pty warnings _sre fnmatch pwd wave _ssl formatter py_compile wcwidth _stat fractions pyclbr weakref _string ftplib pydoc webbrowser _strptime functools pydoc_data wsgiref _struct gc pyexpat xdrlib _symtable genericpath queue xml _sysconfigdata_dm_linux_x86_64-linux-gnu getopt quopri xmlrpc _sysconfigdata_m_linux_x86_64-linux-gnu getpass random xxlimited _testmultiphase gettext re xxsubtype _thread glob readline zipapp _threading_local grp reprlib zipfile _tracemalloc gzip requests zipimport _warnings hashlib resource zlib _weakref heapq rlcompleter Enter any module name to get more help. Or, type "modules spam" to search for modules whose name or summary contain the string "spam". >>>
Popular Recommendations:-
How to Install and Enable EPEL Repository on RHEL/CentOS 7/8{Simple and Easy Steps}
How to Properly Search PHP Modules Using YUM tool in Linux(RHEL/CentOS 7/8)
How to Install and Configure Squid Proxy Server on RHEL/CentOS 7/8
5 Best Ways to Become root user or Superuser in Linux (RHEL/CentOS/Ubuntu)
11 Best Python OS Module Examples on Linux
How to Install MariaDB 5.5 Server on RHEL/CentOS 7 Linux with Easy Steps
6 Simple Steps to Change/Reset MariaDB root password on RHEL/CentOS 7/8