diff --git a/NEWS.md b/NEWS.md index 4af8554bf..1b30c2d6d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,7 @@ # reticulate (development version) +- Fixed error when importing a module named `config` (#1628) + # reticulate 1.38.0 - Python Exceptions converted to R conditions are now R lists instead diff --git a/inst/config/config.py b/inst/config/config.py index b7a362211..55e8a3131 100644 --- a/inst/config/config.py +++ b/inst/config/config.py @@ -33,6 +33,7 @@ def module_path(name): # Get appropriate path-entry separator for platform pathsep = ";" if os.name == "nt" else ":" +this_script_dir = os.path.dirname(__file__) # Read default configuration values # fmt: off @@ -43,7 +44,8 @@ def module_path(name): "Prefix" : getattr(sys, "prefix", ""), "ExecPrefix" : getattr(sys, "exec_prefix", ""), "BaseExecPrefix" : getattr(sys, "base_exec_prefix", ""), - "PythonPath" : pathsep.join((x or "." for x in sys.path)), + "PythonPath" : pathsep.join((x or "." for x in sys.path + if x != this_script_dir)), "LIBPL" : sysconfig.get_config_var("LIBPL"), "LIBDIR" : sysconfig.get_config_var("LIBDIR"), "SharedLibrary" : sysconfig.get_config_var("Py_ENABLE_SHARED"),