My stub python3 program cannot find the "pytz" module:
[me@mybox]$ uname -a
Linux portal2 3.10.0-1160.53.1.el7.x86_64 #1 SMP Fri Jan 14 13:59:45 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
[me@mybox]$ cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)
[me@mybox]$
[me@mybox]$ cat t2b.py
#!/usr/bin/env python3
import sys
import datetime
import time
import pytz
from datetime import datetime, timezone, tzinfo
[me@mybox]$ ./t2b.py
Traceback (most recent call last):
File "./t2b.py", line 6, in <module>
import pytz
ModuleNotFoundError: No module named 'pytz'
[me@mybox]$
"yum" on my Centos 7 box provides the 'pytz' module, so I installed it (many lines deleted):
[root@mybox ~]# yum install pytz
Loaded plugins: fastestmirror, langpacks
Determining fastest mirrors
. . . . .
Resolving Dependencies
--> Running transaction check
---> Package pytz.noarch 0:2016.10-2.el7 will be installed
--> Finished Dependency Resolution
. . . . .
Dependencies Resolved
. . . . .
Installing:
pytz noarch 2016.10-2.el7 base 46 k
. . . . .
Installed:
pytz.noarch 0:2016.10-2.el7
Complete!
[root@mybox ~]#
But after this, my stub program failed in the identical manner! As far as it was concerned, there was still " No module named 'pytz' ", even after a reboot and logging back in.
It was not until after I installed the 'pytz' module via 'pip3' that t2b.py could find it.
[root@portal2 ~]# pip3 install pytz
WARNING: Running pip install with root privileges is generally not a good idea. Try `pip3 install --user` instead.
Collecting pytz
Downloading https://files.pythonhosted.org/packages/d3/e3/d9f046b5d1c94a3aeab15f1f867aa414f8ee9d196fae6865f1d6a0ee1a0b/pytz-2021.3-py2.py3-none-any.whl (503kB)
100% |████████████████████████████████| 512kB 2.0MB/s
Installing collected packages: pytz
Successfully installed pytz-2021.3
[root@portal2 ~]#
[kurt@mybox ]$ ./t2b.py
[kurt@mybox ]$
As far as possible I'd like to uniformly maintain installed software via "yum". My question is why will this not work for this python3 module, and/or what additional steps do I have to take for the process to work properly?