matham/thorcam

Thor.Net binaries not loading

Isquare1 opened this issue · 2 comments

Thank you for the help with my previous questoin, I hope you can help me resolve this as well. After successfully importing thorcam and from thorcam.camera import ThorCam, attempting to start the server with cam.start_cam_process gives me an error :

ERROR:root:No module named 'Thorlabs'
ERROR:root:Traceback (most recent call last):
File "C:\Users\user\anaconda3\lib\site-packages\thorcam\camera.py", line 296, in cam_process
if process.exception:
File "C:\Users\user\anaconda3\lib\site-packages\thorcam\camera.py", line 72, in exception
self._exception = self._pconn.recv()
File "C:\Users\user\anaconda3\lib\multiprocessing\connection.py", line 251, in recv
return _ForkingPickler.loads(buf.getbuffer())
ModuleNotFoundError: No module named 'Thorlabs'

Process ThorCamProcess-1:
Traceback (most recent call last):
File "C:\Users\user\anaconda3\lib\multiprocessing\process.py", line 297, in _bootstrap
self.run()
File "C:\Users\user\anaconda3\lib\site-packages\thorcam\camera.py", line 62, in run
super(ThorCamProcess, self).run()
File "C:\Users\user\anaconda3\lib\multiprocessing\process.py", line 99, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\user\anaconda3\lib\site-packages\thorcam\camera.py", line 48, in camera_dot_net_process_entry
server = ThorCamServer(thor_bin_path, server, port, timeout)
File "C:\Users\user\anaconda3\lib\site-packages\thorcam\camera_dot_net.py", line 622, in init
self.load_tsi(thor_bin_path)
File "C:\Users\user\anaconda3\lib\site-packages\thorcam\camera_dot_net.py", line 641, in load_tsi
self.tsi_sdk = TLCameraSDK.OpenTLCameraSDK()
**Thorlabs.TSI.Core.ConstructorException: Failed to load tsi_sdk.dll. Error code: 1920 Path: 'some/random/path' **
at Thorlabs.TSI.Core.ConstructorCleaner.CleanConstructor(IDisposable objectBeingConstructed, Exception constructingException)
at Thorlabs.TSI.TLCamera.TLCameraSDKInternal..ctor()
at Thorlabs.TSI.TLCamera.TLCameraSDK.OpenTLCameraSDK()

...
...
ERROR:root:[WinError 10061] No connection could be made because the target machine actively refused it
ERROR:root:Traceback (most recent call last):
File "C:\Users\user\anaconda3\lib\site-packages\thorcam\camera.py", line 367, in client_run
sock.connect(server_address)
ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it

Where it says Error code: 1920, I have removed the actual Path, but it basically either gives the current working directory or some other directory..
In camera.py, I checked that thorcam.dep_bins[0], where it should be searching for the dlls, indeed is recognised as share\thorcam\bin and all the dlls (including tsi_sdk.dll) are there. Reading the installation instructions, just in case I also created an env variable THORCAM_NET_BIN_PATH pointing to share\thorcam\bin. So I am at a lost as to why it is looking in the current working directory.
I am not sure what more I can do, without disrupting the source code. Any help will be appreciated again!

Hmm first, can you try setting thor_bin_path here to the full path to the dlls? Do it before starting the camera.

From what I read about this error code, it could be due to permission issues. Can you copy the dlls to some folder that you definitely have permissions to (e.g. on your desktop) and set the above thor_bin_path and see if it fixes it?

Also, perhaps adding the dlls to the path is not working here. So maybe manually add the folder to the PATH environmental variable if you know how to do that.

But to clarify, in the error when it says Error code: 1920 Path: 'some/random/path', is that the full path to where it actually is? Ir is it the relative path? Because the relative path may not work.

Additionally, I never tested thorcam with anaconda myself, so it's possible the dlls distributed by thorcam and included in thorcam wheel is just not compatible with anaconda!?

I've tested thorcam on conda and it worked ok. So I've expanded the install instructions with exact instructions as well as a troubleshooting section that should resolve the issue.

Please read https://matham.github.io/thorcam/installation.html carefully. I'm closing this for now. If after following those steps exactly you still have issues, please re-open or open a new issue.