Installing GDCM on Windows — ImportError

情到浓时终转凉″ 提交于 2021-02-08 08:12:50

问题


I am trying to install GDCM on Windows (10, x64) so I can use the GDCM package with Python 3.6.5, and am finding it completely impossible.

I have tried every combination of:

  • Installing GDCM-2.8.7-Windows-x86_64, GDCM-2.8.7-Windows-x86.exe, GDCM-2.8.4-Windows-x86.exe (separately, of course)
  • Adding To PYTHONPATH: C:\Program Files\Python36; C:\Program Files\Python36\Lib; C:\Program Files\Python36\DLLs; C:\Program Files\Python36\Scripts; C:\Program Files\GDCM 2.8; C:\Program Files\GDCM 2.8\lib; C:\Program Files\GDCM 2.8\bin; C:\Program Files\GDCM 2.8\include; C:\Program Files\GDCM 2.8\ (and even PYTHONHOME)
  • Copying the files gdcm.py, gdcmswig.py and _gdcmswig.pyd into site-packages and DLLs

The best I can get is copying the above mentioned files to site-packages, which allows python to detect the gdcm package (when the files are removed from site-packages it detects nothing), but returns the error:

>>> import gdcm
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Program Files\Python36\lib\site-packages\gdcm.py", line 68, in 
<module>
from gdcmswig import *
File "C:\Program Files\Python36\lib\site-packages\gdcmswig.py", line 20, in 
<module>
_gdcmswig = swig_import_helper()
File "C:\Program Files\Python36\lib\site-packages\gdcmswig.py", line 19, in 
swig_import_helper
return importlib.import_module(mname)
File "C:\Program Files\Python36\lib\importlib\__init__.py", line 126, in 
import_module
return _bootstrap._gcd_import(name[level:], package, level)
ImportError: DLL load failed: The specified module could not be found.

Installing the _x86 version instead returns the error "%1 is not a Valid Win32 application".

I downloaded dependencyWalker to analyse _gdcmswig.pyd, but from this I cannot understand much. The problem is not MSVCP100.dll, as I have vc_redist_x64 installed. It does mention Python34.dll, but the answer below got the exact same installer working on Python 3.6.

The solution mentioned at: how to install gdcm python wrapping on Windows System? does not work for me.

Lastly, I cannot get python to detect the package from the Program Files/GDCM 2.8/bin, regardless of what is in PATH, PYTHONPATH, or PYTHONHOME; I don't know if this is normal or not.

I have spent hours on this, to no avail; any help is greatly appreciated.


回答1:


For posterity:

For me, it seems the issue was indeed that the official provided binaries were compiled for Python 3.4; I have no idea how this person got the same installer working on Python 3.6.

The solution was to build the package binaries myself; there was no "one-click" solution. For my ridiculously convoluted adventure in troubleshooting this problem, see: https://motivatedbylaziness.wordpress.com/2018/07/06/the-impossible-journey-of-a-simple-task/



来源:https://stackoverflow.com/questions/51196377/installing-gdcm-on-windows-importerror

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!