I am just curious why only this library has an error of version check.
Below is the code.
import pydub
print('Pydub version: ', pydub.__version__)
I got the error as below.
AttributeError: module 'pydub' has no attribute '__version__'
Other libraries can print their versions.
I could check the version(0.25.1) of 'pydub' by just installing it in prompt as below.
pip install pydub
Are there anyone who know the reason of an error of version check for 'Pydub'?
Alternatively you can get package version from the subprocess - use something like this:
import subprocess
import re
completed = subprocess.run(["pip", "show", "pydub"], stdout=subprocess.PIPE, encoding="utf-8")
text = completed.stdout
res = re.search("Version: ([0-9]*\.[0-9]*\.[0-9]*)", text)
version = res.group(1)
Or alternatively call the pip
from the python:
from pip._internal.commands import show
tt= show.search_packages_info(['pydub'])
for pkg in tt:
print (pkg.name)
print (pkg.metadata_version)
print (pkg.version)