简体   繁体   English

在 Windows 上安装 GDCM -- ImportError

[英]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.我正在尝试在 Windows (10, x64) 上安装 GDCM,这样我就可以使用 GDCM package 和 Python 和 3.6.

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)安装 GDCM-2.8.7-Windows-x86_64, GDCM-2.8.7-Windows-x86.exe, GDCM-2.8.4-Windows-x86.exe (当然要分开安装)
  • Adding To PYTHONPATH: C:\Program Files\Python36;添加到 PYTHONPATH:C:\Program Files\Python36; C:\Program Files\Python36\Lib; C:\Program Files\Python36\Lib; C:\Program Files\Python36\DLLs; C:\Program Files\Python36\DLLs; C:\Program Files\Python36\Scripts; C:\Program Files\Python36\Scripts; C:\Program Files\GDCM 2.8; C:\Program Files\GDCM 2.8; C:\Program Files\GDCM 2.8\lib; C:\Program Files\GDCM 2.8\lib; C:\Program Files\GDCM 2.8\bin; C:\Program Files\GDCM 2.8\bin; C:\Program Files\GDCM 2.8\include; C:\Program Files\GDCM 2.8\include; C:\Program Files\GDCM 2.8\ (and even PYTHONHOME) C:\Program Files\GDCM 2.8\(甚至 PYTHONHOME)
  • Copying the files gdcm.py, gdcmswig.py and _gdcmswig.pyd into site-packages and DLLs将文件 gdcm.py、gdcmswig.py 和 _gdcmswig.pyd 复制到站点包和 DLL 中

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:我能得到的最好的是将上述文件复制到站点包,这允许 python 检测 gdcm package (当文件从站点包中删除时它什么也没检测到),但返回错误:

>>> 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".安装 _x86 版本会返回错误“%1 不是有效的 Win32 应用程序”。

I downloaded dependencyWalker to analyse _gdcmswig.pyd, but from this I cannot understand much.我下载了dependencyWalker来分析_gdcmswig.pyd,但从中我无法理解太多。 The problem is not MSVCP100.dll, as I have vc_redist_x64 installed.问题不在于 MSVCP100.dll,因为我安装了 vc_redist_x64。 It does mention Python34.dll, but the answer below got the exact same installer working on Python 3.6.它确实提到了 Python34.dll,但下面的答案得到了在 Python 3.6 上工作的完全相同的安装程序。

The solution mentioned at: how to install gdcm python wrapping on Windows System?提到的解决方案: 如何在 Windows 系统上安装 gdcm python 包装? 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;最后,我无法让 python 从 Program Files/GDCM 2.8/bin 中检测 package,无论 PATH、PYTHONPATH 或 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; 对我来说,问题似乎确实是官方提供的二进制文件是针对Python 3.4编译的; I have no idea how this person got the same installer working on Python 3.6. 我不知道这个人如何在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//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看来今天(2022)有“一键式”解决方案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 PyQt 4.7 - 在Windows上安装后的ImportError - PyQt 4.7 - ImportError after installing on Windows 在Windows上安装pymysql ImportError:无法导入名称FIELD_TYPE - installing pymysql on windows ImportError: cannot import name FIELD_TYPE 我在Windows中安装gdcm,然后在python中“导入gdcm”,出现错误 - I install gdcm in windows ,then i “import gdcm” in python, I got anerror Windows 上的 ImportError - ImportError on Windows 安装报纸时的ImportError - ImportError when installing newspaper 在Ubuntu上安装matplotlib:ImportError - Installing matplotlib on Ubuntu: ImportError 在Windows XP上安装mapnik失败,并显示消息“ImportError:DLL加载失败:找不到指定的过程。” - Installing mapnik on Windows XP fails with the message “ImportError: DLL load failed: The specified procedure could not be found.” ImportError:在 Windows/Python 中安装 XGBoost 时没有名为 numpy.distutils.core 的模块 - ImportError: No module named numpy.distutils.core while installing XGBoost in Windows/Python 在virtualenv中安装pip时的ImportError - ImportError while installing pip in virtualenv 在Ubuntu上安装Rasterio失败并出现ImportError - Installing Rasterio on Ubuntu fails with ImportError
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM