尝试导入 gensim 时"ImportError: DLL load failed: The specified module could not be found"



尝试导入gensim时,我遇到了以下错误

Traceback (most recent call last):
File "c:UsersusrDocumentshellotest.py", line 3, in <module>
import gensim
File "C:UsersusrAppDataLocalPackagesPythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0LocalCachelocal-packagesPython37site-packagesgensim__init__.py", line 5, in <module>
from gensim import parsing, corpora, matutils, interfaces, models, similarities, summarization, utils  # noqa:F401
File "C:UsersusrAppDataLocalPackagesPythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0LocalCachelocal-packagesPython37site-packagesgensimcorpora__init__.py", line 6, in <module>
from .indexedcorpus import IndexedCorpus  # noqa:F401 must appear before the other classes
File "C:UsersusrAppDataLocalPackagesPythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0LocalCachelocal-packagesPython37site-packagesgensimcorporaindexedcorpus.py", line 15, in <module>
from gensim import interfaces, utils
File "C:UsersusrAppDataLocalPackagesPythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0LocalCachelocal-packagesPython37site-packagesgensiminterfaces.py", line 21, in <module>
from gensim import utils, matutils
File "C:UsersusrAppDataLocalPackagesPythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0LocalCachelocal-packagesPython37site-packagesgensimmatutils.py", line 21, in <module>
from scipy.stats import entropy
File "C:UsersusrAppDataLocalPackagesPythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0LocalCachelocal-packagesPython37site-packagesscipystats__init__.py", line 384, in <module>
from .stats import *
File "C:UsersusrAppDataLocalPackagesPythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0LocalCachelocal-packagesPython37site-packagesscipystatsstats.py", line 179, in <module>
from scipy.spatial.distance import cdist
File "C:UsersusrAppDataLocalPackagesPythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0LocalCachelocal-packagesPython37site-packagesscipyspatial__init__.py", line 99, in <module>
from .qhull import *
ImportError: DLL load failed: The specified module could not be found.

我尝试在命令提示符下使用pip卸载 numpy、scipy 和 gensim 并再次安装它们,但这并不能解决问题。

我也在这里查看了类似问题的建议,并尝试安装 numpy-1.19.0+mkl-cp37-cp37m-win_amd64.whl,但它导致了一个单独的错误Importing the numpy c-extensions failed.因此,我坚持使用通过pip安装的 numpy、scipy 和 gensim

。此外,我安装了 scipy 版本 1.4.1,因为最新的 1.5.0 版本将给出以下错误,如此链接中所述: 加载 scipy 时出错: OSError: [WinError 126] 找不到指定的模块

任何帮助将不胜感激!

有关其他信息,我使用的是Python 3.7和Windows 10。

我遇到了同样的问题并尝试了各种方法,但唯一对我有用的就是安装旧版本的 Gensim。

pip install gensim==3.7.0

相关内容

最新更新