2020-07-10 09:12:09 +02:00
|
|
|
import sys, os
|
|
|
|
from sysconfig import get_path
|
|
|
|
|
|
|
|
failed_map_path = os.path.join(get_path('stdlib'), '_import_failed', 'import_failed.map')
|
|
|
|
|
|
|
|
if __spec__:
|
|
|
|
failed_name = __spec__.name
|
|
|
|
else:
|
|
|
|
failed_name = __name__
|
|
|
|
|
2021-05-02 19:07:37 +02:00
|
|
|
with open(failed_map_path) as fd:
|
|
|
|
for line in fd:
|
|
|
|
package = line.split(':')[0]
|
|
|
|
imports = line.split(':')[1]
|
|
|
|
if failed_name in imports:
|
|
|
|
raise ImportError(f"""Module '{failed_name}' is not installed.
|
2020-07-10 09:12:09 +02:00
|
|
|
Use:
|
|
|
|
sudo zypper install {package}
|
|
|
|
to install it.""")
|
|
|
|
|
|
|
|
raise ImportError(f"""Module '{failed_name}' is not installed.
|
|
|
|
It is supposed to be part of python3 distribution, but missing from failed import map.
|
|
|
|
Please file a bug on the SUSE Bugzilla.""")
|