简体   繁体   中英

Installing GDCM on Windows -- ImportError

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.

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/

I recently had this issue, and I solved it using:

python -m pip install python-gdcm

It seems that today (2022) there is a "one-click" solution

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM