Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error Loading DLL, Windows 11, TH260N #33

Closed
jpalm-pv opened this issue Aug 23, 2024 · 4 comments
Closed

Error Loading DLL, Windows 11, TH260N #33

jpalm-pv opened this issue Aug 23, 2024 · 4 comments
Labels
good first issue Good for newcomers

Comments

@jpalm-pv
Copy link

Describe the bug
Hello. I am experiencing an inconsistent error in loading the "snAPI64.dll" file. This may be due to my own ignorance, but I'm out of troubleshooting ideas.

Screenshot 1 shows the command line output when I run my program. It fails on initialization of a snAPI object (self.sn = snAPI()).

However, if I restart the kernel and in the command line I initialize a snAPI object (from snAPI.Main import *; sn = snAPI(), Screenshot 2), the device connects just fine. If I then close the device and exit the API (sn.closeDevice(); sn.exitAPI()), I can run my program without issues.

This error occurred when I was setting up this system, but as if by magic, it disappeared. This issue has resurfaced with zero changes to the system.

Trouble Shooting I Have Tried

  • Uninstalled/Reinstalled python 3.12
  • Update C++ Redist
  • Restart computer
  • Run command line as administrator

Screenshots
Screenshot 1:
DirectlyRunPrgm

Screenshot 2:
CmdLineFirst

System Specs:
SystemSpecs

Additional context
Thanks in advance for your help!

@tpoint75
Copy link
Collaborator

Could it be, the restart fixed it? The redistributable wants a restart, if I remeber right!

@tpoint75
Copy link
Collaborator

Are you using anaconda?

@jpalm-pv
Copy link
Author

Unfortunately, a restart did not fix it. I actually tried it with anaconda when first setting up the system and I couldn't initialize a snAPI() object at all (it was giving the same OS Error). Then I went through the install instructions more carefully, and noticed that you recommended a "regular" python install, not with conda. This worked for a while but now the error has resurfaced.

@jpalm-pv
Copy link
Author

I fixed it! I used the process monitor for Windows to monitor processes in the Failed and Successful cases, then compared the processes. The problem was related to using PyQt5 in the same script as snAPI. Apparently, PyQt5 looks for the DLL "MSVCP140.dll" in its own directories before checking the system directories, which was interfering with snAPI's ability to load the correct version of this DLL.

The solution was to import and initialize the snAPI package and object before importing PyQt5. This ensures that snAPI loads its required DLLs from the correct locations (typically system directories) before PyQt5 has a chance to interfere with the DLL search path.

This approach allows snAPI to resolve its dependencies correctly, avoiding conflicts with PyQt5's bundled DLLs. If you're experiencing similar issues with snAPI and PyQt5 (or other large libraries with bundled DLLs), try reorganizing your imports to prioritize snAPI's initialization.

@tpoint75 tpoint75 pinned this issue Aug 27, 2024
@tpoint75 tpoint75 added the good first issue Good for newcomers label Aug 27, 2024
@tpoint75 tpoint75 closed this as completed Sep 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants