Why not import?

[mysql@centos7 ~]$ pip list
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at Release process - pip documentation v24.1.dev1 pip 21.0 will remove support for this functionality.
Package Version


configobj 4.7.2
decorator 3.4.0
iniparse 0.4
IPy 0.75
mysql 0.0.1
MySQL-python 1.2.5
perf 0.1
pip 20.3.4
policycoreutils-default-encoding 0.1
pycurl 7.19.0
pygobject 3.22.0
pygpgme 0.3
pyliblzma 0.5.3
python-linux-procfs 0.4.9
pyudev 0.15
pyxattr 0.5.1
schedutils 0.4
seobject 0.1
sepolicy 1.1
setuptools 44.1.1
slip 0.4.0
slip.dbus 0.4.0
urlgrabber 3.10
wheel 0.37.1
yum-metadata-parser 1.1.4
[mysql@centos7 ~] [mysql@centos7 ~]
[mysql@centos7 ~] python check_mysql.py Traceback (most recent call last): File "check_mysql.py", line 4, in <module> import mysql ImportError: No module named mysql [mysql@centos7 ~]

Why didn’t MySQL import it in

thanks

[mysql@centos7 ~]$ python check_mysql.py
Traceback (most recent call last):
File “check_mysql.py”, line 4, in
import mysql
ImportError: No module named mysql

Could you format your question better please.

[mysql@centos7 ~] pip list DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality. [...] mysql 0.0.1 MySQL-python 1.2.5 [...] [mysql@centos7 ~] python check_mysql.py
Traceback (most recent call last):
File “check_mysql.py”, line 4, in
import mysql
ImportError: No module named mysql
[mysql@centos7 ~]$

The usual reason for this is that the Python used by pip is not the
same Python which is invoked by python. Try this:

 python -m pip list

which inherently uses the Python which python invokes.

But also: please move to python3. Python 2 is long gone, not even
pining for the fjords. So try invoking python3 for all of the above.

  • [mysql@centos7 ~]$ python -m pip list
  • DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at Release process - pip documentation v24.1.dev1 pip 21.0 will remove support for this functionality.
  • Package Version

  • configobj 4.7.2
  • decorator 3.4.0
  • iniparse 0.4
  • IPy 0.75
  • mysql 0.0.1
  • MySQL-python 1.2.5
  • perf 0.1
  • pip 20.3.4
  • policycoreutils-default-encoding 0.1
  • pycurl 7.19.0
  • pygobject 3.22.0
  • pygpgme 0.3
  • pyliblzma 0.5.3
  • python-linux-procfs 0.4.9
  • pyudev 0.15
  • pyxattr 0.5.1
  • schedutils 0.4
  • seobject 0.1
  • sepolicy 1.1
  • setuptools 44.1.1
  • slip 0.4.0
  • slip.dbus 0.4.0
  • urlgrabber 3.10
  • wheel 0.37.1
  • yum-metadata-parser 1.1.4