【gensim安装】import gensim报错 Compiled extensions are unavailable.

在这个网站https://www.lfd.uci.edu/~gohlke/pythonlibs/找到和自己的python对应版本的gensim安装即可,numpy和scipy也得是对应版本,我的python是3.6,操作系统64位,所以下的是gensim-3.8.3-cp36-cp36m-win_amd64
下载完进入cmd,定位到这个文件在的位置,输入pip install gensim-3.8.3-cp36-cp36m-win_amd64.whl即可

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
很抱歉,我在上面给出的代码中犯了一个误。gensim的DTM模型不再位于`gensim.models.wrappers`模块中,而是位于`gensim.models.dtmmodel`模块中。请尝试使用以下代码: ```python from gensim.models import DtmModel from gensim.corpora import Dictionary # 读取文档数据 documents = [ "This is the first document", "This document is the second document", "And this is the third one", "Is this the first document?" ] # 创建词典 dictionary = Dictionary([doc.lower().split() for doc in documents]) # 创建语料库 corpus = [dictionary.doc2bow(doc.lower().split()) for doc in documents] # 指定DTM的路径 dtm_path = '/path/to/dtm/binary' # 指定DTM的参数 dtm_params = { 'model': dtm_path, 'corpus': corpus, 'id2word': dictionary, 'num_topics': 3, # 设定主题数量 'time_slices': [1, 1, 1, 1], # 设定时间切片,这里假设每个文档都属于一个时间切片 } # 创建DTM模型 dtm_model = DtmModel(**dtm_params) # 获取文档的主题分布 doc_topics = dtm_model.get_document_topics(corpus) # 打印每个文档的主题分布 for i, doc in enumerate(doc_topics): print(f"Document {i+1}: {doc}") ``` 请确保将`/path/to/dtm/binary`替换为实际的DTM二进制文件路径。如果仍然遇到问题,请确保已正确安装gensim库,并尝试更新到最新版本。如果问题仍然存在,请尝试重新安装gensim。 非常抱歉给你带来了困扰,希望这次能够解决问题。如果还有其他问题,请随时提问。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值