Hdbscan: 导入 hdbscan 时出错

创建于 2015-12-04  ·  10评论  ·  资料来源: scikit-learn-contrib/hdbscan

尝试执行时出现以下错误:import hdbscan

我在 Windows 7 机器上,使用 conda 安装了 64 位 python

错误 :

ImportError                               Traceback (most recent call last)
<ipython-input-12-3f1c79fb1b69> in <module>()
----> 1 import hdbscan

c:\anaconda2\lib\site-packages\hdbscan-0.6.2-py2.7-macosx-10.5-x86_64.egg\hdbscan\__init__.py in <module>()

c:\anaconda2\lib\site-packages\hdbscan-0.6.2-py2.7-macosx-10.5-x86_64.egg\hdbscan\hdbscan_.py in <module>()

c:\anaconda2\lib\site-packages\hdbscan-0.6.2-py2.7-macosx-10.5-x86_64.egg\hdbscan\_hdbscan_linkage.py in <module>()

c:\anaconda2\lib\site-packages\hdbscan-0.6.2-py2.7-macosx-10.5-x86_64.egg\hdbscan\_hdbscan_linkage.py in __bootstrap__()

ImportError: DLL load failed: %1 is not a valid Win32 application.

最有用的评论

这确实是点子。 但我认为问题是由于 numpy 需要 cython 1.10 及更高版本。 安装 Cython 时安装得很好。感谢您的快速回复

所有10条评论

我对构建 conda 包有点陌生; 不幸的是,看起来我还有一些学习要做。 这是我构建的 conda 包的错误。 如果您通过 conda(主要是 scikit-learn 和 cython)安装您的需求,然后使用 pip install 或从源代码安装,事情应该会解决。 谢谢你的报告。 我将不得不调查 conda 包装问题,看看我是否能理解那里出了什么问题。

谢谢你这么快的回复。

安装还是不行。 我已经尝试过 conda 32 位包和 64 位包。 有没有其他方法可以让它工作。

在pip安装的情况下,错误是:

[Anaconda2] C:\Users\user_name>pip install hdbscan
Collecting hdbscan
  Using cached hdbscan-0.6.2.tar.gz
Requirement already satisfied (use --upgrade to upgrade): scikit-learn>=0.16 in
c:\anaconda2\lib\site-packages (from hdbscan)
Requirement already satisfied (use --upgrade to upgrade): cython>=0.17 in c:\ana
conda2\lib\site-packages (from hdbscan)
Building wheels for collected packages: hdbscan
  Running setup.py bdist_wheel for hdbscan
  Complete output from command C:\Anaconda2\python.exe -c "import setuptools;__f
ile__='c:\\users\\user_name\\appdata\\local\\temp\\pip-build-yf7q3s\\hdbscan\\setup.
py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))
" bdist_wheel -d c:\users\user_name\appdata\local\temp\tmpbmg3edpip-wheel-:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win-amd64-2.7
  creating build\lib.win-amd64-2.7\hdbscan
  copying hdbscan\hdbscan_.py -> build\lib.win-amd64-2.7\hdbscan
  copying hdbscan\plots.py -> build\lib.win-amd64-2.7\hdbscan
  copying hdbscan\robust_single_linkage_.py -> build\lib.win-amd64-2.7\hdbscan
  copying hdbscan\__init__.py -> build\lib.win-amd64-2.7\hdbscan
  running build_ext
  skipping 'hdbscan\_hdbscan_tree.c' Cython extension (up-to-date)
  building 'hdbscan._hdbscan_tree' extension
  creating build\temp.win-amd64-2.7
  creating build\temp.win-amd64-2.7\Release
  creating build\temp.win-amd64-2.7\Release\hdbscan
  C:\Users\user_name\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9
.0\VC\Bin\amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -IC:\Anaconda2\lib\s
ite-packages\numpy\core\include -IC:\Anaconda2\include -IC:\Anaconda2\PC /Tchdbs
can\_hdbscan_tree.c /Fobuild\temp.win-amd64-2.7\Release\hdbscan\_hdbscan_tree.ob
j
  _hdbscan_tree.c
  c:\anaconda2\lib\site-packages\numpy\core\include\numpy\npy_1_7_deprecated_api
.h(12) : Warning Msg: Using deprecated NumPy API, disable it by #defining NPY_NO
_DEPRECATED_API NPY_1_7_API_VERSION
  hdbscan\_hdbscan_tree.c(2560) : warning C4244: 'function' : conversion from '_
_pyx_t_5numpy_intp_t' to 'long', possible loss of data
  hdbscan\_hdbscan_tree.c(2787) : warning C4244: '=' : conversion from '__pyx_t_
5numpy_intp_t' to 'int', possible loss of data
  hdbscan\_hdbscan_tree.c(2820) : warning C4244: '+=' : conversion from 'Py_ssiz
e_t' to 'long', possible loss of data
  hdbscan\_hdbscan_tree.c(2831) : warning C4244: '+=' : conversion from 'Py_ssiz
e_t' to 'long', possible loss of data
  hdbscan\_hdbscan_tree.c(2842) : warning C4244: '+=' : conversion from 'Py_ssiz
e_t' to 'long', possible loss of data
  hdbscan\_hdbscan_tree.c(2854) : warning C4244: '+=' : conversion from 'Py_ssiz
e_t' to 'long', possible loss of data
  hdbscan\_hdbscan_tree.c(2899) : warning C4244: '=' : conversion from '__pyx_t_
5numpy_intp_t' to 'int', possible loss of data
  hdbscan\_hdbscan_tree.c(2940) : warning C4244: '=' : conversion from '__pyx_t_
5numpy_intp_t' to 'int', possible loss of data
  hdbscan\_hdbscan_tree.c(4122) : warning C4244: 'function' : conversion from '_
_pyx_t_5numpy_intp_t' to 'long', possible loss of data
  hdbscan\_hdbscan_tree.c(5242) : warning C4244: 'function' : conversion from '_
_pyx_t_5numpy_intp_t' to 'long', possible loss of data
  hdbscan\_hdbscan_tree.c(6278) : warning C4244: 'function' : conversion from '_
_pyx_t_5numpy_intp_t' to 'long', possible loss of data
  hdbscan\_hdbscan_tree.c(6351) : warning C4244: 'function' : conversion from '_
_pyx_t_5numpy_intp_t' to 'long', possible loss of data
  hdbscan\_hdbscan_tree.c(21049) : error C2275: 'PyGILState_STATE' : illegal use
 of this type as an expression
          C:\Anaconda2\include\pystate.h(137) : see declaration of 'PyGILState_S
TATE'
  hdbscan\_hdbscan_tree.c(21049) : error C2146: syntax error : missing ';' befor
e identifier '__pyx_gilstate_save'
  hdbscan\_hdbscan_tree.c(21049) : error C2065: '__pyx_gilstate_save' : undeclar
ed identifier
  hdbscan\_hdbscan_tree.c(21120) : error C2065: '__pyx_gilstate_save' : undeclar
ed identifier
  hdbscan\_hdbscan_tree.c(21146) : error C2275: 'PyGILState_STATE' : illegal use
 of this type as an expression
          C:\Anaconda2\include\pystate.h(137) : see declaration of 'PyGILState_S
TATE'
  hdbscan\_hdbscan_tree.c(21146) : error C2146: syntax error : missing ';' befor
e identifier '__pyx_gilstate_save'
  hdbscan\_hdbscan_tree.c(21146) : error C2065: '__pyx_gilstate_save' : undeclar
ed identifier
  hdbscan\_hdbscan_tree.c(21219) : error C2065: '__pyx_gilstate_save' : undeclar
ed identifier
  hdbscan\_hdbscan_tree.c(21246) : error C2275: 'PyGILState_STATE' : illegal use
 of this type as an expression
          C:\Anaconda2\include\pystate.h(137) : see declaration of 'PyGILState_S
TATE'
  hdbscan\_hdbscan_tree.c(21246) : error C2146: syntax error : missing ';' befor
e identifier '__pyx_gilstate_save'
  hdbscan\_hdbscan_tree.c(21246) : error C2065: '__pyx_gilstate_save' : undeclar
ed identifier
  hdbscan\_hdbscan_tree.c(21336) : error C2065: '__pyx_gilstate_save' : undeclar
ed identifier
  hdbscan\_hdbscan_tree.c(22003) : error C2275: 'PyGILState_STATE' : illegal use
 of this type as an expression
          C:\Anaconda2\include\pystate.h(137) : see declaration of 'PyGILState_S
TATE'
  hdbscan\_hdbscan_tree.c(22003) : error C2146: syntax error : missing ';' befor
e identifier '__pyx_gilstate_save'
  hdbscan\_hdbscan_tree.c(22003) : error C2065: '__pyx_gilstate_save' : undeclar
ed identifier
  hdbscan\_hdbscan_tree.c(22029) : error C2065: '__pyx_gilstate_save' : undeclar
ed identifier
  error: command 'C:\\Users\\user_name\\AppData\\Local\\Programs\\Common\\Microsoft\
\Visual C++ for Python\\9.0\\VC\\Bin\\amd64\\cl.exe' failed with exit status 2

  ----------------------------------------
  Failed building wheel for hdbscan
Failed to build hdbscan
Installing collected packages: hdbscan
  Running setup.py install for hdbscan
    Complete output from command C:\Anaconda2\python.exe -c "import setuptools,
tokenize;__file__='c:\\users\\user_name\\appdata\\local\\temp\\pip-build-yf7q3s\\hdb
scan\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().re
place('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\user_name\appdata
\local\temp\pip-a6ueto-record\install-record.txt --single-version-externally-man
aged --compile:
    running install
    running build
    running build_py
    running build_ext
    skipping 'hdbscan\_hdbscan_tree.c' Cython extension (up-to-date)
    building 'hdbscan._hdbscan_tree' extension
    C:\Users\user_name\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python
\9.0\VC\Bin\amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -IC:\Anaconda2\lib
\site-packages\numpy\core\include -IC:\Anaconda2\include -IC:\Anaconda2\PC /Tchd
bscan\_hdbscan_tree.c /Fobuild\temp.win-amd64-2.7\Release\hdbscan\_hdbscan_tree.
obj
    _hdbscan_tree.c
    c:\anaconda2\lib\site-packages\numpy\core\include\numpy\npy_1_7_deprecated_a
pi.h(12) : Warning Msg: Using deprecated NumPy API, disable it by #defining NPY_
NO_DEPRECATED_API NPY_1_7_API_VERSION
    hdbscan\_hdbscan_tree.c(2560) : warning C4244: 'function' : conversion from
'__pyx_t_5numpy_intp_t' to 'long', possible loss of data
    hdbscan\_hdbscan_tree.c(2787) : warning C4244: '=' : conversion from '__pyx_
t_5numpy_intp_t' to 'int', possible loss of data
    hdbscan\_hdbscan_tree.c(2820) : warning C4244: '+=' : conversion from 'Py_ss
ize_t' to 'long', possible loss of data
    hdbscan\_hdbscan_tree.c(2831) : warning C4244: '+=' : conversion from 'Py_ss
ize_t' to 'long', possible loss of data
    hdbscan\_hdbscan_tree.c(2842) : warning C4244: '+=' : conversion from 'Py_ss
ize_t' to 'long', possible loss of data
    hdbscan\_hdbscan_tree.c(2854) : warning C4244: '+=' : conversion from 'Py_ss
ize_t' to 'long', possible loss of data
    hdbscan\_hdbscan_tree.c(2899) : warning C4244: '=' : conversion from '__pyx_
t_5numpy_intp_t' to 'int', possible loss of data
    hdbscan\_hdbscan_tree.c(2940) : warning C4244: '=' : conversion from '__pyx_
t_5numpy_intp_t' to 'int', possible loss of data
    hdbscan\_hdbscan_tree.c(4122) : warning C4244: 'function' : conversion from
'__pyx_t_5numpy_intp_t' to 'long', possible loss of data
    hdbscan\_hdbscan_tree.c(5242) : warning C4244: 'function' : conversion from
'__pyx_t_5numpy_intp_t' to 'long', possible loss of data
    hdbscan\_hdbscan_tree.c(6278) : warning C4244: 'function' : conversion from
'__pyx_t_5numpy_intp_t' to 'long', possible loss of data
    hdbscan\_hdbscan_tree.c(6351) : warning C4244: 'function' : conversion from
'__pyx_t_5numpy_intp_t' to 'long', possible loss of data
    hdbscan\_hdbscan_tree.c(21049) : error C2275: 'PyGILState_STATE' : illegal u
se of this type as an expression
            C:\Anaconda2\include\pystate.h(137) : see declaration of 'PyGILState
_STATE'
    hdbscan\_hdbscan_tree.c(21049) : error C2146: syntax error : missing ';' bef
ore identifier '__pyx_gilstate_save'
    hdbscan\_hdbscan_tree.c(21049) : error C2065: '__pyx_gilstate_save' : undecl
ared identifier
    hdbscan\_hdbscan_tree.c(21120) : error C2065: '__pyx_gilstate_save' : undecl
ared identifier
    hdbscan\_hdbscan_tree.c(21146) : error C2275: 'PyGILState_STATE' : illegal u
se of this type as an expression
            C:\Anaconda2\include\pystate.h(137) : see declaration of 'PyGILState
_STATE'
    hdbscan\_hdbscan_tree.c(21146) : error C2146: syntax error : missing ';' bef
ore identifier '__pyx_gilstate_save'
    hdbscan\_hdbscan_tree.c(21146) : error C2065: '__pyx_gilstate_save' : undecl
ared identifier
    hdbscan\_hdbscan_tree.c(21219) : error C2065: '__pyx_gilstate_save' : undecl
ared identifier
    hdbscan\_hdbscan_tree.c(21246) : error C2275: 'PyGILState_STATE' : illegal u
se of this type as an expression
            C:\Anaconda2\include\pystate.h(137) : see declaration of 'PyGILState
_STATE'
    hdbscan\_hdbscan_tree.c(21246) : error C2146: syntax error : missing ';' bef
ore identifier '__pyx_gilstate_save'
    hdbscan\_hdbscan_tree.c(21246) : error C2065: '__pyx_gilstate_save' : undecl
ared identifier
    hdbscan\_hdbscan_tree.c(21336) : error C2065: '__pyx_gilstate_save' : undecl
ared identifier
    hdbscan\_hdbscan_tree.c(22003) : error C2275: 'PyGILState_STATE' : illegal u
se of this type as an expression
            C:\Anaconda2\include\pystate.h(137) : see declaration of 'PyGILState
_STATE'
    hdbscan\_hdbscan_tree.c(22003) : error C2146: syntax error : missing ';' bef
ore identifier '__pyx_gilstate_save'
    hdbscan\_hdbscan_tree.c(22003) : error C2065: '__pyx_gilstate_save' : undecl
ared identifier
    hdbscan\_hdbscan_tree.c(22029) : error C2065: '__pyx_gilstate_save' : undecl
ared identifier
    error: command 'C:\\Users\\user_name\\AppData\\Local\\Programs\\Common\\Microsof
t\\Visual C++ for Python\\9.0\\VC\\Bin\\amd64\\cl.exe' failed with exit status 2


    ----------------------------------------
Command "C:\Anaconda2\python.exe -c "import setuptools, tokenize;__file__='c:\\u
sers\\user_name\\appdata\\local\\temp\\pip-build-yf7q3s\\hdbscan\\setup.py';exec(com
pile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __f
ile__, 'exec'))" install --record c:\users\user_name\appdata\local\temp\pip-a6ueto-r
ecord\install-record.txt --single-version-externally-managed --compile" failed w
ith error code 1 in c:\users\user_name\appdata\local\temp\pip-build-yf7q3s\hdbscan

如果是手动安装:

F:\downloads\hdbscan-master\hdbscan-master>python setup.py install
running install
running bdist_egg
running egg_info
writing requirements to hdbscan.egg-info\requires.txt
writing hdbscan.egg-info\PKG-INFO
writing top-level names to hdbscan.egg-info\top_level.txt
writing dependency_links to hdbscan.egg-info\dependency_links.txt
reading manifest file 'hdbscan.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'hdbscan.egg-info\SOURCES.txt'
installing library code to build\bdist.win-amd64\egg
running install_lib
running build_py
creating build\lib.win-amd64-2.7
creating build\lib.win-amd64-2.7\hdbscan
copying hdbscan\hdbscan_.py -> build\lib.win-amd64-2.7\hdbscan
copying hdbscan\plots.py -> build\lib.win-amd64-2.7\hdbscan
copying hdbscan\robust_single_linkage_.py -> build\lib.win-amd64-2.7\hdbscan
copying hdbscan\__init__.py -> build\lib.win-amd64-2.7\hdbscan
running build_ext
skipping 'hdbscan\_hdbscan_tree.c' Cython extension (up-to-date)
building 'hdbscan._hdbscan_tree' extension
creating build\temp.win-amd64-2.7
creating build\temp.win-amd64-2.7\Release
creating build\temp.win-amd64-2.7\Release\hdbscan
C:\Users\Intel\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0
\VC\Bin\amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -IC:\Anaconda2\lib\sit
e-packages\numpy\core\include -IC:\Anaconda2\include -IC:\Anaconda2\PC /Tchdbsca
n\_hdbscan_tree.c /Fobuild\temp.win-amd64-2.7\Release\hdbscan\_hdbscan_tree.obj
_hdbscan_tree.c
c:\anaconda2\lib\site-packages\numpy\core\include\numpy\npy_1_7_deprecated_api.h
(12) : Warning Msg: Using deprecated NumPy API, disable it by #defining NPY_NO_D
EPRECATED_API NPY_1_7_API_VERSION
hdbscan\_hdbscan_tree.c(2560) : warning C4244: 'function' : conversion from '__p
yx_t_5numpy_intp_t' to 'long', possible loss of data
hdbscan\_hdbscan_tree.c(2787) : warning C4244: '=' : conversion from '__pyx_t_5n
umpy_intp_t' to 'int', possible loss of data
hdbscan\_hdbscan_tree.c(2820) : warning C4244: '+=' : conversion from 'Py_ssize_
t' to 'long', possible loss of data
hdbscan\_hdbscan_tree.c(2831) : warning C4244: '+=' : conversion from 'Py_ssize_
t' to 'long', possible loss of data
hdbscan\_hdbscan_tree.c(2842) : warning C4244: '+=' : conversion from 'Py_ssize_
t' to 'long', possible loss of data
hdbscan\_hdbscan_tree.c(2854) : warning C4244: '+=' : conversion from 'Py_ssize_
t' to 'long', possible loss of data
hdbscan\_hdbscan_tree.c(2899) : warning C4244: '=' : conversion from '__pyx_t_5n
umpy_intp_t' to 'int', possible loss of data
hdbscan\_hdbscan_tree.c(2940) : warning C4244: '=' : conversion from '__pyx_t_5n
umpy_intp_t' to 'int', possible loss of data
hdbscan\_hdbscan_tree.c(4122) : warning C4244: 'function' : conversion from '__p
yx_t_5numpy_intp_t' to 'long', possible loss of data
hdbscan\_hdbscan_tree.c(5242) : warning C4244: 'function' : conversion from '__p
yx_t_5numpy_intp_t' to 'long', possible loss of data
hdbscan\_hdbscan_tree.c(6278) : warning C4244: 'function' : conversion from '__p
yx_t_5numpy_intp_t' to 'long', possible loss of data
hdbscan\_hdbscan_tree.c(6351) : warning C4244: 'function' : conversion from '__p
yx_t_5numpy_intp_t' to 'long', possible loss of data
hdbscan\_hdbscan_tree.c(21049) : error C2275: 'PyGILState_STATE' : illegal use o
f this type as an expression
        C:\Anaconda2\include\pystate.h(137) : see declaration of 'PyGILState_STA
TE'
hdbscan\_hdbscan_tree.c(21049) : error C2146: syntax error : missing ';' before
identifier '__pyx_gilstate_save'
hdbscan\_hdbscan_tree.c(21049) : error C2065: '__pyx_gilstate_save' : undeclared
 identifier
hdbscan\_hdbscan_tree.c(21120) : error C2065: '__pyx_gilstate_save' : undeclared
 identifier
hdbscan\_hdbscan_tree.c(21146) : error C2275: 'PyGILState_STATE' : illegal use o
f this type as an expression
        C:\Anaconda2\include\pystate.h(137) : see declaration of 'PyGILState_STA
TE'
hdbscan\_hdbscan_tree.c(21146) : error C2146: syntax error : missing ';' before
identifier '__pyx_gilstate_save'
hdbscan\_hdbscan_tree.c(21146) : error C2065: '__pyx_gilstate_save' : undeclared
 identifier
hdbscan\_hdbscan_tree.c(21219) : error C2065: '__pyx_gilstate_save' : undeclared
 identifier
hdbscan\_hdbscan_tree.c(21246) : error C2275: 'PyGILState_STATE' : illegal use o
f this type as an expression
        C:\Anaconda2\include\pystate.h(137) : see declaration of 'PyGILState_STA
TE'
hdbscan\_hdbscan_tree.c(21246) : error C2146: syntax error : missing ';' before
identifier '__pyx_gilstate_save'
hdbscan\_hdbscan_tree.c(21246) : error C2065: '__pyx_gilstate_save' : undeclared
 identifier
hdbscan\_hdbscan_tree.c(21336) : error C2065: '__pyx_gilstate_save' : undeclared
 identifier
hdbscan\_hdbscan_tree.c(22003) : error C2275: 'PyGILState_STATE' : illegal use o
f this type as an expression
        C:\Anaconda2\include\pystate.h(137) : see declaration of 'PyGILState_STA
TE'
hdbscan\_hdbscan_tree.c(22003) : error C2146: syntax error : missing ';' before
identifier '__pyx_gilstate_save'
hdbscan\_hdbscan_tree.c(22003) : error C2065: '__pyx_gilstate_save' : undeclared
 identifier
hdbscan\_hdbscan_tree.c(22029) : error C2065: '__pyx_gilstate_save' : undeclared
 identifier
error: command 'C:\\Users\\user_name\\AppData\\Local\\Programs\\Common\\Microsoft\\V
isual C++ for Python\\9.0\\VC\\Bin\\amd64\\cl.exe' failed with exit status 2

那看起来很糟糕。 我真的不太确定这里出了什么问题——我在 Windows 上安装的经验很少。 我建议使用手动安装并删除 hdbscan 目录中的所有 .c 文件; IE

hdbscan/_hdbscan_tree.c
hdbscan/_hdbscan_boruvka.x
hdbscan/_hdbscan_linkage.c
hdbscan/_hdbscan_reachability.c

然后再次尝试构建; Windows 不喜欢 C 文件中的某些内容。

我在 Ubuntu 上试过。 它在 Ubuntu 上运行良好

我很高兴你设法让它工作。 对 Windows 上的问题感到抱歉(Windows 似乎是我最大的问题来源)。 我暂时将这个问题悬而未决; 团队中的其他一些人可以访问他们可以测试的 Windows 系统,我们将尝试解决 Windows 问题。 感谢问题报告!

利姆辛斯,
不幸的是,我在 win7 64 env 中收到与上述相同的错误消息。
问候
哈里

在这一点上,我必须向具有 Windows 经验/知识的任何人寻求帮助。 似乎在 Linux 和 MacOS X(我可以访问的环境)上一切正常,至少有时可以在 Windows 上工作......任何有在 Windows 上编译经验的人的帮助将不胜感激!

作为旁注; 这是最近失败的 pip 安装吗? 前几天我试图为 win64 添加一个轮包,这是由一位乐于助人的人提供的——也许这导致了问题?

这确实是点子。 但我认为问题是由于 numpy 需要 cython 1.10 及更高版本。 安装 Cython 时安装得很好。感谢您的快速回复

可以确认,必须先安装cython然后在ubuntu 16.04上安装hdbscan

此页面是否有帮助?
0 / 5 - 0 等级