media2x/rife-ncnn-vulkan-python

ImportError: DLL load failed while importing _rife_ncnn_vulkan_wrapper: The specified module could not be found.

dsmanneke opened this issue · 9 comments

when you try to import the module: "from rife_ncnn_vulkan import RIFE"
the following error will come:
Traceback (most recent call last):
File ".\run_test.py", line 1, in
from rife_ncnn_vulkan import RIFE
File "C:\Users%username%\Projects\Restoration_GUI\rife\rife_ncnn_vulkan.py", line 12, in
import rife_ncnn_vulkan_wrapper as raw
File "C:\Users%username%\Projects\Restoration_GUI\rife\rife_ncnn_vulkan_wrapper.py", line 15, in
import _rife_ncnn_vulkan_wrapper
ImportError: DLL load failed while importing _rife_ncnn_vulkan_wrapper: The specified module could not be found.

I download the following file:
When downloading rife-ncnn-vulkan-python-20210504-windows.zip

This is also the case for previous builds

Thank you for your issue.

The release package hasn't been fully tested under windows, so your issues reminded me to have a look at the behavior of it on windows.

I have downloaded the release package and had a short check on the zip archive (I am busy working on my assignments recently, so I can only have short checks before I am have time to boot up my windows machine for testing the issue.). I found that the DLL lib file "rife-ncnn-vulkan-python-20210504-windows/_rife_ncnn_vulkan_wrapper.pyd" is there. So I think 🤔 it should work. Could you have a look at where "_rife_ncnn_vulkan_wrapper.pyd" is and check if it is located within the same folder with _rife_ncnn_vulkan_wrapper.py?

Thank you for answering quickly.

I checked and the file is located in the folder. To be sure, here is my terminal output ;)

 Directory: C:\Users\%username%\Projects\Restoration_GUI\rife_ncnn
  
  
 Mode            LastWriteTime         Length Name
 ----                 -------------         ------ ----
 d-----         5/16/2021   5:40 PM             models
 d-----         5/16/2021   6:47 PM            __pycache__
 -a----         5/16/2021   6:47 PM           1098 LICENSE
 -a----         5/16/2021   6:47 PM           3459 README.md
 -a----         5/16/2021   6:47 PM           2507 rife_ncnn_vulkan.py
 -a----         5/16/2021   6:47 PM           6100 rife_ncnn_vulkan_wrapper.py
 -a----         5/16/2021   6:45 PM             35 run_test.py
 -a----         5/16/2021   6:47 PM         177552 vcomp140.dll
 -a----         5/16/2021   6:47 PM        3821056 _rife_ncnn_vulkan_wrapper.dll
 -a----         5/16/2021   6:47 PM        3821056 _rife_ncnn_vulkan_wrapper.pyd
  
  
  PS C:\Users\%username%\Projects\Restoration_GUI\rife_ncnn> python.exe .\run_test.py
  Traceback (most recent call last):
    File ".\run_test.py", line 1, in <module>
      from rife_ncnn_vulkan import RIFE
    File "C:\Users\%username%\Projects\Restoration_GUI\rife_ncnn\rife_ncnn_vulkan.py", line 12, in <module>
      import rife_ncnn_vulkan_wrapper as raw
    File "C:\Users\%username%\Projects\Restoration_GUI\rife_ncnn\rife_ncnn_vulkan_wrapper.py", line 15, in <module>
      import _rife_ncnn_vulkan_wrapper
  ImportError: DLL load failed while importing _rife_ncnn_vulkan_wrapper: The specified module could not be found.

Here is also my python version

PS C:\Users\%username%\Projects\Restoration_GUI\rife_ncnn> python.exe -VV
Python 3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:57:54) [MSC v.1924 64 bit (AMD64)]

Thank you for answering quickly.

I checked and the file is located in the folder. To be sure, here is my terminal output ;)

 Directory: C:\Users\%username%\Projects\Restoration_GUI\rife_ncnn
  
  
 Mode            LastWriteTime         Length Name
 ----                 -------------         ------ ----
 d-----         5/16/2021   5:40 PM             models
 d-----         5/16/2021   6:47 PM            __pycache__
 -a----         5/16/2021   6:47 PM           1098 LICENSE
 -a----         5/16/2021   6:47 PM           3459 README.md
 -a----         5/16/2021   6:47 PM           2507 rife_ncnn_vulkan.py
 -a----         5/16/2021   6:47 PM           6100 rife_ncnn_vulkan_wrapper.py
 -a----         5/16/2021   6:45 PM             35 run_test.py
 -a----         5/16/2021   6:47 PM         177552 vcomp140.dll
 -a----         5/16/2021   6:47 PM        3821056 _rife_ncnn_vulkan_wrapper.dll
 -a----         5/16/2021   6:47 PM        3821056 _rife_ncnn_vulkan_wrapper.pyd
  
  
  PS C:\Users\%username%\Projects\Restoration_GUI\rife_ncnn> python.exe .\run_test.py
  Traceback (most recent call last):
    File ".\run_test.py", line 1, in <module>
      from rife_ncnn_vulkan import RIFE
    File "C:\Users\%username%\Projects\Restoration_GUI\rife_ncnn\rife_ncnn_vulkan.py", line 12, in <module>
      import rife_ncnn_vulkan_wrapper as raw
    File "C:\Users\%username%\Projects\Restoration_GUI\rife_ncnn\rife_ncnn_vulkan_wrapper.py", line 15, in <module>
      import _rife_ncnn_vulkan_wrapper
  ImportError: DLL load failed while importing _rife_ncnn_vulkan_wrapper: The specified module could not be found.

Here is also my python version

PS C:\Users\%username%\Projects\Restoration_GUI\rife_ncnn> python.exe -VV
Python 3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:57:54) [MSC v.1924 64 bit (AMD64)]

I confirmed that the problem exists. It is caused by CMake compilie configurations which might binded the compiled lib with the host's python lib. In other words, the current rife-ncnn-vulkan-python windows build can only be run with python 3.7.9. Even python 3.7.8, python 3.8.5 and python 3.9.5 will fail to run it. However, this was supposed to be already fixed in previous commits which solved such problems on Linux platforms.
I will try to fix it in the next build. At the present, you can try to compile it on your own computers. The best reference is release.yml which is the configurations for generating windows releases with Github Action. You can just look at the run sections in the windows parts.
I hope these contents are helpful to you.

Sorry to tell you that this issue is quite complicated to solve. Since the upstream has already got two version updates to follow, I need to make new release now.
I will fix this issue once I find a solution in the future. Before that, I am sorry that you may need to compile it on your own or use python 3.9 which is the python version on the compile machine.
Or do you think compiling this lib for popular python versions on Windows is good?

Could you try the new binaries?
https://github.com/media2x/rife-ncnn-vulkan-python/releases/tag/1.1.1

Unfortunately, the rife pyd still points to python310.dll In the latest 1.1.1 build
2054FD93-D502-48D1-B64B-77231E17FF35
C6A794CF-C016-409B-8719-77979B3F51DC

Btw, I also tried manually building by MSVC after cloning the whole project. the import also crashes loading under my python 3.7.9 env. The cmake config could be still problematic.

#5 This fixed my issue in my fork after referring to other media2x closed issues, the pyd now can link to python37.dll correctly

#5 This fixed my issue in my fork after referring to other media2x closed issues, the pyd now can link to python37.dll correctly

Thank you for your PR. We forgot to add the PY_VERSION patch after @k4yt3x implemented the download tricks in setup.py.
@dsmanneke Could you use the latest build to see if the problem is solved? https://github.com/media2x/rife-ncnn-vulkan-python/releases/tag/1.1.2-2