diff --git a/src/python_coupling/PythonCallback.cpp b/src/python_coupling/PythonCallback.cpp
index c469b10dfc877aeee8a83af26dbe153032cdc181..507087fc9f84f2524f05f720b0a5fdfb9ec7cd06 100644
--- a/src/python_coupling/PythonCallback.cpp
+++ b/src/python_coupling/PythonCallback.cpp
@@ -77,17 +77,21 @@ namespace python_coupling {
 
       std::string cwd(cwd_buf);
       std::free(cwd_buf);
+      path = filesystem::absolute( path, cwd );
 #else
-      filesystem::path cwd = filesystem::current_path();
+      path = filesystem::absolute( path );
 #endif
-      path = filesystem::absolute( path, cwd );
       if ( path.extension() == ".py" )
       {
          moduleName = path.stem().string();
 
 
          if ( ! path.parent_path().empty() )  {
+#ifdef CURRENT_PATH_WORKAROUND
             std::string p = filesystem::canonical(path.parent_path(), cwd).string();
+#else
+            std::string p = filesystem::canonical(path.parent_path()).string();
+#endif
             code << "sys.path.append( r'" << p << "')" << "\n";
          }
       }