Table of contents
Background & Problem Description
Recently I encountered a very magical problem. The module that had been installed through pip3 pydub
suddenly became unusable and an error was reported.
ModuleNotFoundError: No module named 'pydub'
When executed pip3 list | grep pydub
, there is corresponding output, proving that it has indeed been installed.
$ pip3 list | grep pydub
pydub 0.25.1
I also had the same problem after trying it reinstall
. I searched online for a long time and found no effective solution.
However, after my investigation, I finally found the problem:
$ python3 -V
Python 3.6.8
$ which python3
/usr/bin/python3
$ ls -l /usr/bin/python3
lrwxrwxrwx 1 root root 9 Jun 27 11:26 /usr/bin/python3 -> python3.6
$ pip3 -V
pip 23.1.2 from /usr/local/python3/lib/python3.8/site-packages/pip (python 3.8)
It was found that the python version pointed to by this command is inconsistent with the python versionpython3
pointed by pip3 . This is the problem.
solution
Just set the python version pip3
pointed python3
to to the same path. In my environment, I set it to the 3.8 version corresponding to pip3, which is achieved by modifying the soft link:
$ ln -s /usr/local/python3/bin/python3.8 /usr/bin/python3
Verify whether the modification is successful
$ which python3
/usr/bin/python3
$ ls -l /usr/bin/python3
lrwxrwxrwx 1 root root 32 Jul 13 17:32 /usr/bin/python3 -> /usr/local/python3/bin/python3.8
$ python3
Python 3.8.1 (default, Feb 9 2023, 20:00:12)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pydub
>>>
OK, no problem. At this point, the problem is solved.