I have recently encountered a problem trying to use the py3nj package on Windows. After a successful installation in a virtual environment, I tried to use it in a script, and got the following error:
$ py smatrix_py3nj.py Traceback (most recent call last): File "C:\Users\User\Documents\python\molscat_data\molscat_data\smatrix_py3nj.py", line 8, in <module> from py3nj import wigner3j as wigner_3j File "C:\Users\User\Documents\python\molscat_data\venv\Lib\site-packages\py3nj\__init__.py", line 13, in <module> from .wigner import wigner3j, wigner6j, wigner9j, clebsch_gordan File "C:\Users\User\Documents\python\molscat_data\venv\Lib\site-packages\py3nj\wigner.py", line 2, in <module> from py3nj import _wigner ImportError: DLL load failed while importing _wigner: The specified module could not be found.
Apparently, the DLLs are only loaded from trusted locations on Windows with Python 3.8 and higher (as described here). I solved it by adding the .libs directory to the DLL locations by adding os.add_dll_directory(extra_dll_dir) to the init.py file. Do you think it's worth including in future versions of the package?
Thank you for reporting the issue.
Right now the windows support is not sufficient as I have no windows machines. The addition is very welcome.
Could you send a PR with it?
Hi,
I have recently encountered a problem trying to use the py3nj package on Windows. After a successful installation in a virtual environment, I tried to use it in a script, and got the following error:
$ py smatrix_py3nj.py Traceback (most recent call last): File "C:\Users\User\Documents\python\molscat_data\molscat_data\smatrix_py3nj.py", line 8, in <module> from py3nj import wigner3j as wigner_3j File "C:\Users\User\Documents\python\molscat_data\venv\Lib\site-packages\py3nj\__init__.py", line 13, in <module> from .wigner import wigner3j, wigner6j, wigner9j, clebsch_gordan File "C:\Users\User\Documents\python\molscat_data\venv\Lib\site-packages\py3nj\wigner.py", line 2, in <module> from py3nj import _wigner ImportError: DLL load failed while importing _wigner: The specified module could not be found.
Apparently, the DLLs are only loaded from trusted locations on Windows with Python 3.8 and higher (as described here). I solved it by adding the .libs directory to the DLL locations by adding
os.add_dll_directory(extra_dll_dir)
to the init.py file. Do you think it's worth including in future versions of the package?