in src/advisor/helpers/python/python_version_checker.py [0:0]
def get_package_version(package_name):
"""Get the installed version of a specific package if it's installed
Args:
package_name: The name of the package
Returns:
str: The installed package version
or None if it's not installed
"""
try:
pip_process = subprocess.run(['pip3', 'show', package_name], capture_output=True)
result = pip_process.stdout.decode('utf-8')
lines = result.split('\n')
if (len(lines) > 1):
version_line = result.split('\n')[1]
return version_line.split()[1]
except:
logging.debug('Error checking python package version.', exc_info=True)
return None