diff --git a/api/GenApi.py b/api/GenApi.py
index a32b270857e75e823ed12a562fb2d231ab6b541f..d2df61fbfb073996bfcbee7cb0066cb071a34b89 100644
--- a/api/GenApi.py
+++ b/api/GenApi.py
@@ -1145,13 +1145,15 @@ else:
     libdir = os.path.dirname(os.path.dirname(moduledir))
 
 libpath = os.path.join(libdir, libname)
+if not os.path.exists(libpath):
+    libpath = os.path.join(libdir, "Lib", libname)
 if not os.path.exists(libpath):
     libpath = os.path.join(moduledir, libname)
-    if not os.path.exists(libpath):
-        if platform.system() == "Windows":
-            libpath = find_library("{7}-{3}.{4}")
-        else:
-            libpath = find_library("{7}")
+if not os.path.exists(libpath):
+    if platform.system() == "Windows":
+        libpath = find_library("{7}-{3}.{4}")
+    else:
+        libpath = find_library("{7}")
 
 lib = CDLL(libpath)
 
diff --git a/api/gmsh.py b/api/gmsh.py
index 73d3baf9153934b38217c85cdc57bc519e003e6b..e2e468f0d3631db65ce8f7eb5303a0afe3ceea45 100644
--- a/api/gmsh.py
+++ b/api/gmsh.py
@@ -38,13 +38,15 @@ else:
     libdir = os.path.dirname(os.path.dirname(moduledir))
 
 libpath = os.path.join(libdir, libname)
+if not os.path.exists(libpath):
+    libpath = os.path.join(libdir, "Lib", libname)
 if not os.path.exists(libpath):
     libpath = os.path.join(moduledir, libname)
-    if not os.path.exists(libpath):
-        if platform.system() == "Windows":
-            libpath = find_library("gmsh-4.9")
-        else:
-            libpath = find_library("gmsh")
+if not os.path.exists(libpath):
+    if platform.system() == "Windows":
+        libpath = find_library("gmsh-4.9")
+    else:
+        libpath = find_library("gmsh")
 
 lib = CDLL(libpath)