Skip to content

Commit

Permalink
Merge pull request #12934 from KratosMultiphysics/core/error-handling
Browse files Browse the repository at this point in the history
[Core] Adding suggestions to import failures
  • Loading branch information
roigcarlo authored Dec 12, 2024
2 parents 7575e9f + ade16f7 commit 2d84b45
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion kratos/python_interface/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,28 @@ class KratosPaths(object):
# import core library (Kratos.so)
sys.path.append(KratosPaths.kratos_libs)
sys.path.append(KratosPaths.kratos_module_libs)
from Kratos import *

try:
from Kratos import *
except ImportError as e:
var_name = {
"posix": "LD_LIBRARY_PATH or DYLD_LIBRARY_PATH",
"nt": "PATH"
}

if os.name in var_name.keys():
print(f"Unable to find KratosCore. Please make sure that your {var_name[os.name]} environment variable includes the path to the Kratos libraries.")
else:
print(f"Unable to find KratosCore. Your OS is unknown and we cannot provide further info. Please open an issue at https://github.com/KratosMultiphysics/Kratos")

raise e

except OSError as e:
if os.name == 'nt':
print("Please download the latest Microsfot Visual C++ Redistributable from https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist")
else:
print("Please make sure that the Kratos libraries are compiled for your system.")
raise e

Kernel.RegisterPythonVersion()

Expand Down

0 comments on commit 2d84b45

Please sign in to comment.