Skip to content

Commit 0b6bf2b

Browse files
authored
Add DLL Search Paths for Windows with Python 3.8+
Aims to Fix #457
1 parent 8403d74 commit 0b6bf2b

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

pysrc/juliacall/__init__.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,22 @@ def backtrace(self):
5050

5151
def init():
5252
import os
53+
## For Windows and Python 3.8+ need to add dll search paths
54+
import sys
55+
if os.name == "nt" and sys.hexversion >= 0x308000:
56+
conda_environment_path = os.environ["CONDA_PREFIX"]
57+
dll_search_paths = [
58+
conda_environment_path,
59+
os.path.join(conda_environment_path, "Library", "mingw-w64", "bin"),
60+
os.path.join(conda_environment_path, "Library", "usr", "bin"),
61+
os.path.join(conda_environment_path, "Library", "bin"),
62+
os.path.join(conda_environment_path, "Scripts"),
63+
os.path.join(conda_environment_path, "bin")
64+
]
65+
for path in dll_search_paths:
66+
if os.path.exists(path):
67+
os.add_dll_directory(path)
68+
5369
import ctypes as c
5470
import sys
5571
import subprocess

0 commit comments

Comments
 (0)