from importlib.metadata import version, PackageNotFoundError import platform import traceback import tkinter COURSE_PYTHON_VERSION = '3.10' COURSE_MIN_RECOMMENDED_PYTHON_VERSION = '3.10' def verify_python_installation(): print('\n< Verifying python installation... >') python_version = platform.python_version() python_version_major_minor = '.'.join(python_version.split('.')[:2]) print(f'\tYour python version: {python_version}') if python_version_major_minor != COURSE_PYTHON_VERSION: warning_msg = f'\t~ Your python version is not the same as the version used by the course ({COURSE_PYTHON_VERSION}).\n'\ f'\t~ The minimum recommended version is {COURSE_MIN_RECOMMENDED_PYTHON_VERSION}.' print(warning_msg) else: print(f'\t✅ Recommended version ({COURSE_PYTHON_VERSION}) installed!') def verify_libraries_installation(): print('\n< Verifying installation of libraries... >') dependencies = ['numpy', 'opencv-python'] try: for pkg in dependencies: pkg_version = version(pkg) print(f'\t{pkg} {pkg_version}') print('\t✅ All libraries installed!') except PackageNotFoundError as e: print(f'\t⚠️ Missing library: {pkg}') print(traceback.format_exc()) print(f'Please retry the installation process. You are missing the <{pkg}> package.') except Exception as e: print('\t❌️ Error') print(traceback.format_exc()) if __name__ == '__main__': verify_python_installation() verify_libraries_installation()