ModuleNotFoundError:没有名为“ fasttext”的模块

时间:2019-10-01 14:18:09

标签: python anaconda conda fasttext

我尝试使用两个渠道通过conda安装fasttext

conda install -c conda-forge fasttext

conda install -c conda-forge/label/cf201901 fasttext

按照(this link)。

我正在使用以下命令导入:import fasttext 但是,导入失败并显示以下错误:

  

ModuleNotFoundError跟踪(最近一次调用)   最后)   ----> 1导入fasttext

     

ModuleNotFoundError:没有名为“ fasttext”的模块

但是,尝试以较旧的方式import fastText导入它,但失败了。

pythonpython3上都尝试过,但都失败了。

我想避免使用pip安装它,而避免使用conda管理软件包。

conda list显示正在安装fasttext。其输出如下所示:

fasttext 0.2.0 hfc679d8_1 conda-forge/label/cf201901

python -c 'import sys; print(sys.path)的输出如下:

['', '/<dir>/<dir>/anaconda3/lib/python37.zip', '/<dir>/<dir>/anaconda3/lib/python3.7', '/<dir>/<dir>/anaconda3/lib/python3.7/lib-dynload', '/<dir>/<dir>/anaconda3/lib/python3.7/site-packages']

1 个答案:

答案 0 :(得分:2)

我以这种方式使用了fastText

!git clone https://github.com/facebookresearch/fastText.git
!cd fastText
!pip install fastText
import fasttext.util
fasttext.util.download_model('en', if_exists='ignore')  # English
model = fasttext.load_model('cc.en.300.bin')

注1:注意大写字母。

注意2:Here是受支持的语言的列表。