apriltags icon indicating copy to clipboard operation
apriltags copied to clipboard

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

Open marceau45800 opened this issue 3 years ago • 6 comments

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

  • Python 3.8.5
  • Windows 10

marceau45800 avatar Jun 11 '21 09:06 marceau45800

I had the same problem, did you solve it?

Randy-W avatar Oct 09 '21 02:10 Randy-W

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

gggdttt avatar Feb 23 '22 22:02 gggdttt

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.

MichaelCurrie avatar Mar 27 '22 14:03 MichaelCurrie

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

shan0987 avatar Sep 15 '22 06:09 shan0987

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...

  • installation with pip install pupil-apriltags in conda environment
    • pupil-apriltags==1.0.4.post10
    • Python==3.9.16
    • Windows 10 Enterprise - 10.0.19045
  • when trying to create detector Error message showed that missing module is C:/Users/username/Miniconda3/envs/my_env/lib/site-packages/pupil_apriltags/libapriltag.dll with same errors as @marceau45800 mentioned
  • found out thanks to dll-diagnostics that this dll library is dependent on these libraries
(my_env) C:\>dlldiag trace C:/Users/username/Miniconda3/envs/my_env/lib/site-packages/pupil_apriltags/lib/apriltag.dll   
DLL Diagnostic Tools version 0.0.18
Copyright (c) 2019-2021 Adam Rehn

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:

os.add_dll_directory("C:/Users/username/Miniconda3/envs/my_env/lib/site-packages/pupil_apriltags.libs")

It worked for me.

Fiiila avatar Jun 20 '23 14:06 Fiiila

any updates about this open issue?

nadavof avatar Jul 27 '23 11:07 nadavof