gpt4 book ai didi

python - 如何在python中安装gensim并运行包?

转载 作者:行者123 更新时间:2023-11-30 09:15:26 25 4
gpt4 key购买 nike

我想在 python 3.7.4 中执行以下操作:

并收到此错误:

我已经尝试过:

使用condapip

使用本地Windows和Windows服务器

多次重新安装不同版本的软件包(例如 numpyscipy)

from gensim.models import Word2Vec 

Traceback (most recent call last): File "c:/Users/Administrator/Documents/GitHub/contract-criteria-identifier-on-aws/schnelltest.py", line 1, in import gensim File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\gensim__init__.py", line 5, in from gensim import parsing, corpora, matutils, interfaces, models, similarities, summarization, utils # noqa:F401 File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\gensim\parsing__init__.py", line 4, in from .preprocessing import (remove_stopwords, strip_punctuation, strip_punctuation2, # noqa:F401 File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\gensim\parsing\preprocessing.py", line 42, in from gensim import utils File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\gensim\utils.py", line 40, in import scipy.sparse File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\scipy\sparse__init__.py", line 230, in from .csr import * File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\scipy\sparse\csr.py", line 13, in from ._sparsetools import (csr_tocsc, csr_tobsr, csr_count_blocks, ImportError: DLL load failed: The specified module could not be found. PS C:\Users\Administrator\Documents\GitHub\contract-criteria-identifier-on-aws> & C:/Users/Administrator/AppData/Local/Programs/Python/Python37/python.exe c:/Users/Administrator/Documents/GitHub/contract-criteria-identifier-on-aws/schnelltest.py Traceback (most recent call last): File "c:/Users/Administrator/Documents/GitHub/contract-criteria-identifier-on-aws/schnelltest.py", line 1, in import gensim File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\gensim__init__.py", line 5, in from gensim import parsing, corpora, matutils, interfaces, models, similarities, summarization, utils # noqa:F401 File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\gensim\parsing__init__.py", line 4, in from .preprocessing import (remove_stopwords, strip_punctuation, strip_punctuation2, # noqa:F401 File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\gensim\parsing\preprocessing.py", line 42, in from gensim import utils File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\gensim\utils.py", line 40, in import scipy.sparse File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\scipy\sparse__init__.py", line 230, in from .csr import * File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\scipy\sparse\csr.py", line 13, in from ._sparsetools import (csr_tocsc, csr_tobsr, csr_count_blocks, ImportError: DLL load failed: The specified module could not be found.

最佳答案

该错误实际上表明 scipy 安装中存在一些问题 - 这是出现 DLL load failed 错误的实际代码行的来源。你应该尝试:

(1) 卸载并重新安装 conda

(2) 确保您已激活“conda 环境”

(3) 手动 conda 安装单独需要的软件包,例如 scipy,并仔细观察输出是否有任何警告/错误

(4) 当最终运行你的代码时,仍然确保你已经激活了正确的 conda 环境

如果您仍然遇到问题,请使用有关每个部件的安装方式以及每个步骤是否报告成功或失败的更具体详细信息来扩展您的问题。

值得注意的是,conda 通常对于让这些包在 Windows 下运行非常有帮助。但总的来说,它们在更多类 Unix/Linux 系统下都得到了最多的开发、使用和质量关注。因此,如果您可以选择不使用 Windows,那么一切都可能有更好的机会工作,并且当您遇到问题时,您将有更多的先前文档/帮助可供引用。 (这一切仍然可以在 Windows 上运行,但通常需要使用辅助或不太优选的安装/配置选项。)

关于python - 如何在python中安装gensim并运行包?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57298877/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com