wollmanlab / JSTA

14 stars 6 forks source link

error when import JSTA #3

Closed lidanwu closed 3 years ago

lidanwu commented 3 years ago

Hello there, When I import JSTA in jupyter notebook, I got the following error. Any suggestions on how to fix it?

---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
<ipython-input-4-38e51191b552> in <module>
----> 1 from JSTA import *

E:\for_JISA\JSTA\CoreFunctions\JSTA.py in <module>
   1048          ndpointer(dtype=np.uintp,ndim=1,flags='C')]
   1049 
-> 1050 dist_func_c = ctypes.CDLL(path_to_file+"/get_distances.so")
   1051 get_d = dist_func_c.get_distances
   1052 dist_func_c.get_distances.argtypes = c_args

c:\programdata\anaconda3\envs\testpy37\lib\ctypes\__init__.py in __init__(self, name, mode, handle, use_errno, use_last_error)
    354 
    355         if handle is None:
--> 356             self._handle = _dlopen(self._name, mode)
    357         else:
    358             self._handle = handle

OSError: [WinError 126] The specified module could not be found

I have tried to create get_distances.so from the get_distances.c file using gcc. But I got the exact same error with .so file in the CoreFunctions folder (path_to_file).

rlittman16 commented 3 years ago

Hello!

Did you use the install.sh file?

lidanwu commented 3 years ago

Thanks for the response. Yes. I created a new conda environment with python = 3.7 and then navigated to the JSTA folder and did

conda install --file CoreFunctions/requirements.txt
install.sh
rlittman16 commented 3 years ago

Hmm, this may be a windows specific problem. I only tested JSTA on unix based systems. I wonder if this would help: https://stackoverflow.com/questions/1940578/windowserror-error-126-the-specified-module-could-not-be-found

In CoreFunctions/JSTA.py you could change path_to_file accordingly and see if that helps

lidanwu commented 3 years ago

Yes, it's an environment thing. I have created the .dll files from .c files using Visual Studio and the loading of cypes.cdll is working now. Just for future reference, the .dll files must be built with correct bit-version and C++ instead of C. The .c files also need to be modified to enable function export.

__declspec(dllexport) void __cdecl get_distances
__declspec(dllexport) int __cdecl get_raveled_index
__declspec(dllexport) void __cdecl get_sur