Getting a
RuntimeError: Can not find Ghostscript DLL in registry
after setting PATH to ghostscript dynamically in Python. I have verified that gsdll64.dll
exists in GhostscriptAppbin
. I do not have admin privileges and therefore cannot directly add ghostscript to PATH. I have installed ghostscript portably which is why I have to dynamically alter the PATH. The error is arising when I use the camelot library and the Ghostscript package that camelot imports fails to locate the Ghostscript DLL. I have tried checking the updated os.environ["PATH"]
and the new path is successfully joined.
def update_app_path(app_name, new_app_path, new_dll_name):
existing_paths = [Path(p) for p in os.environ["PATH"].split(os.path.pathsep)]
filtered_paths = [p for p in existing_paths if not (p / app_name).exists()]
new_path_object = Path(new_app_path)
filtered_paths.append(new_path_object)
os.environ["PATH"] = os.path.pathsep.join(map(str, filtered_paths))
dll_path = new_path_object / new_dll_name
os.environ['GS_DLL'] = str(dll_path)
update_app_path('ghostscript', r"C:UsersUserDownloadsCommonFilesGhostscriptAppbin", 'gsdll64.dll')
Can anyone suggest what may be going wrong with my approach?
Petesh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.