fujiisoup / py3nj

Wigner's 3J, 6J, 9J symbols for python
https://py3nj.readthedocs.io/
Apache License 2.0
19 stars 5 forks source link

DLL not found #6

Closed hartytp closed 4 years ago

hartytp commented 4 years ago

After installing on windows 10 with python 3.7.6 I was getting

    from py3nj import _wigner
ImportError: DLL load failed: The specified module could not be found.

After a bit of digging, it looks like python isn't picking up the DLL located in .libs. I haven't dug too much into the exact source of the issue but, from a quick skim, it looks somewhat like https://github.com/scipy/scipy/issues/11062

Adding the following to my __init__.py resolves the issue

import os
import sys
extra_dll_dir = os.path.join(os.path.dirname(__file__), '.libs')

if sys.platform == 'win32' and os.path.isdir(extra_dll_dir):
    os.environ.setdefault('PATH', '')
    os.environ['PATH'] += os.pathsep + extra_dll_dir

Happy to submit a PR if it helps?

fujiisoup commented 4 years ago

Thanks, @hartytp

A PR is absolutely welcome. I have not checked with Windows, as I have no windows...