Cyberithub

Python3: ModuleNotFoundError: No module named “prettytable” in Linux

Python Developers or programmers often get the error "ModuleNotFoundError: No module named 'prettytable" while trying to run their python program. Are you also getting the same"ModuleNotFoundError: No module named 'prettytable'" error ? Are you looking for a command to install Python prettytable module on Linux Servers ? If yes, then I am going to explain you about the different commands which can be used to install prettytable module for Python3 on Linux Servers.

Python3: ModuleNotFoundError: No module named "prettytable" in Linux

Python3: ModuleNotFoundError: No module named ‘prettytable’ in Linux

Also Read: How to Install and Enable EPEL Repository on RHEL/CentOS 7/8{Simple and Easy Steps}

If want to install python3 modules in your server then you need to use python3 -m pip install <python_module> command to install that specific module. Since here our requirement is to install the prettytable module so you need to use python3 -m pip install prettytable command to install this module as you can see below. It is worth mentioning here that this command requires you to have python3 already installed in your Server. So if it is not installed then you can check How to Install Python3 on CentOS 7 article to know more about the installation steps.

[root@localhost ~]# python3 -m pip install prettytable
WARNING: Running pip install with root privileges is generally not a good idea. Try `__main__.py install --user` instead.
Collecting prettytable
  Downloading https://files.pythonhosted.org/packages/39/da/8336296a830caa495a25304e12ffb32a8c3a9d2d08ba995f066fe16152e1/prettytable-1.0.1-py2.py3-none-any.whl
Requirement already satisfied: setuptools in /usr/lib/python3.6/site-packages (from prettytable)
Collecting wcwidth (from prettytable)
  Downloading https://files.pythonhosted.org/packages/59/7c/e39aca596badaf1b78e8f547c807b04dae603a433d3e7a7e04d67f2ef3e5/wcwidth-0.2.5-py2.py3-none-any.whl
Installing collected packages: wcwidth, prettytable
Successfully installed prettytable-1.0.1 wcwidth-0.2.5

NOTE:

Please note that although for the sake of demonstration I am installing module here with root privileges but this is not the recommended way in Production or in Critical Servers. Installing module using pip utility causing the setup.py script to run on the backend. This might be disastrous if any attacker planted the malicious code there with the same name.

You can also uninstall prettytable module using python3 -m pip uninstall prettytable command once you are done with it. Similarly if you want to uninstall any other python modules using python3 then you need to use python3 -m pip uninstall <python_module_name> command.

[root@localhost ~]# python3 -m pip uninstall prettytable
Uninstalling prettytable-1.0.1:
  /usr/local/lib/python3.6/site-packages/__pycache__/prettytable.cpython-36.pyc
  /usr/local/lib/python3.6/site-packages/prettytable-1.0.1.dist-info/COPYING
  /usr/local/lib/python3.6/site-packages/prettytable-1.0.1.dist-info/INSTALLER
  /usr/local/lib/python3.6/site-packages/prettytable-1.0.1.dist-info/METADATA
  /usr/local/lib/python3.6/site-packages/prettytable-1.0.1.dist-info/RECORD
  /usr/local/lib/python3.6/site-packages/prettytable-1.0.1.dist-info/WHEEL
  /usr/local/lib/python3.6/site-packages/prettytable-1.0.1.dist-info/top_level.txt
  /usr/local/lib/python3.6/site-packages/prettytable.py
Proceed (y/n)? y
  Successfully uninstalled prettytable-1.0.1

Another important method that you can use to install the prettytable module is through pip3.6 tool for python3. Pip3.6 is a python installer package used for managing python programs and modules. You can use pip3.6 install prettytable command to install prettytable module on Linux servers. Like prettytable module, you can install other python modules as well by using pip3.6 install <python_module> command.

[root@localhost ~]# pip3.6 install prettytable
WARNING: Running pip install with root privileges is generally not a good idea. Try `pip3.6 install --user` instead.
Collecting prettytable
  Using cached https://files.pythonhosted.org/packages/39/da/8336296a830caa495a25304e12ffb32a8c3a9d2d08ba995f066fe16152e1/prettytable-1.0.1-py2.py3-none-any.whl
Requirement already satisfied: setuptools in /usr/lib/python3.6/site-packages (from prettytable)
Requirement already satisfied: wcwidth in /usr/local/lib/python3.6/site-packages (from prettytable)
Installing collected packages: prettytable
Successfully installed prettytable-1.0.1

If you want to uninstall prettytable module then you can do it by using pip3.6 uninstall prettytable command as shown below. Similarly if you want to uninstall any other python modules using pip3.6 utility then you need to use pip3.6 uninstall <python_module_name> command. So you can use pip3.6 tool for installation as well as for uninstallation of python modules. More can be checked on pip Official Documentation.

[root@localhost ~]#pip3.6 uninstall prettytable
Uninstalling prettytable-1.0.1:
/usr/local/lib/python3.6/site-packages/__pycache__/prettytable.cpython-36.pyc
/usr/local/lib/python3.6/site-packages/prettytable-1.0.1.dist-info/COPYING
/usr/local/lib/python3.6/site-packages/prettytable-1.0.1.dist-info/INSTALLER
/usr/local/lib/python3.6/site-packages/prettytable-1.0.1.dist-info/METADATA
/usr/local/lib/python3.6/site-packages/prettytable-1.0.1.dist-info/RECORD
/usr/local/lib/python3.6/site-packages/prettytable-1.0.1.dist-info/WHEEL
/usr/local/lib/python3.6/site-packages/prettytable-1.0.1.dist-info/top_level.txt
/usr/local/lib/python3.6/site-packages/prettytable.py
Proceed (y/n)? y
Successfully uninstalled prettytable-1.0.1

Hopefully this article helped you solving "ModuleNotFoundError: No module named 'prettytable" error.
 

 

Popular Recommendations:-

Solved: FATAL: Authentication Helper Program /usr/lib/squid/basic_ncsa_auth: (2) No Such File or Directory

How to Install and Configure Squid Proxy Server on RHEL/CentOS 7/8

Primitive Data Types in Java – int, char, byte, short, long, float, double and boolean

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

Best Steps to Install Java on RHEL 8/CentOS 8

Leave a Comment