pupil-labs / apriltags

Python bindings for the apriltags3 library
https://pupil-apriltags.readthedocs.io/en/latest/index.html
Other
106 stars 29 forks source link

Python pupil_Apriltags : Problem with DLL path “Could not find module” #38

Open marceau45800 opened 3 years ago

marceau45800 commented 3 years ago

Hello I have a problem with pupil_apriltags in python. I have been searching for more than 1 week and tried multiple solutions but none of them worked.

My problem is not with the import of the librairy but when I try to create the detector. There is a reference to a xxxx.dll file (I think) which does not work.

My code

Very simple

from pupil_apriltags import Detector
import cv2
import numpy as np

at_detector = Detector(families='tag36h11',
                       nthreads=1,
                       quad_decimate=1.0,
                       quad_sigma=0.0,
                       refine_edges=1,
                       decode_sharpening=0.25,
                       debug=0)

My error

Traceback (most recent call last):                                                                                  
File "detection_apriltags.py", line 6, in <module>                                                                        
at_detector = Detector()                                                                                              
File "C:\Users\Utilisateur\anaconda3\lib\site-packages\pupil_apriltags\bindings.py", line 285, in __init__
self.libc = ctypes.CDLL(str(hit))                                                                                     
File "C:\Users\Utilisateur\anaconda3\lib\ctypes\__init__.py", line 381, in __init__                                       
self._handle = _dlopen(self._name, mode)                                                                            
FileNotFoundError: Could not find module 'C:\Users\Utilisateur\anaconda3\lib\site-
packages\pupil_apriltags\lib\apriltag.dll' (or one of its dependencies). Try using the full path 
with constructor syntax.

My configuration

Randy-W commented 3 years ago

I had the same problem, did you solve it?

gggdttt commented 2 years ago

image image It seems that we need to change the path here. But I don't know how to change...

MichaelCurrie commented 2 years ago

Same question is here:

https://stackoverflow.com/questions/67919822/python-pupil-apriltags-problem-with-dll-path-could-not-find-module

Answer:

I had the same problem, apparently the .dll search mechanism changed in python 3.8 You can see more details of how to fix it here.

I made a PR into this repo to fix the issue. See https://github.com/pupil-labs/apriltags/pull/48

After this PR is accepted this issue can be closed, I believe.

shan0987 commented 2 years ago

Hi I have the same issue. Just wondering if you have fixed this issue?

Fiiila commented 1 year ago

Problem

Hi there, just recently experienced the same problem with FileNotFoundError: Could not find module 'path/to/existing/dll'. Problem was caused by dependent libraries in different folder.

In my case...

Parsing module header and identifying non delay-loaded dependencies... done.

Identifying the module's delay-loaded dependencies... done.

Parsed module details: Module: C:\Users\username\Miniconda3\envs\my_env\lib\site-packages\pupil_apriltags\lib\apriltag.dll Type: Dynamic-Link Library Architecture: x64

The module imports 12 direct dependencies: api-ms-win-crt-convert-l1-1-0.dll api-ms-win-crt-environment-l1-1-0.dll api-ms-win-crt-heap-l1-1-0.dll api-ms-win-crt-math-l1-1-0.dll api-ms-win-crt-runtime-l1-1-0.dll api-ms-win-crt-stdio-l1-1-0.dll api-ms-win-crt-string-l1-1-0.dll api-ms-win-crt-utility-l1-1-0.dll KERNEL32.dll pthreadVC2.dll VCRUNTIME140.dll WINMM.dll

Error: no debugger found for architecture x64. Please ensure the Debugging Tools for Windows 10 (WinDbg) are installed correctly.

- just looked around and found this folder with libraries `C:\Users\username\Miniconda3\envs\my_env\lib\site-packages\pupil_apriltags.libs`

# Solution
just add this line before creating Detector instance:
```python
os.add_dll_directory("C:/Users/username/Miniconda3/envs/my_env/lib/site-packages/pupil_apriltags.libs")

It worked for me.

nadavof commented 1 year ago

any updates about this open issue?