1、确保安装过此包
安装命令为:
pip install fastText
2、我遇到的问题是安装成功,但是import仍然找不到
具体问题如下:
(nlp) ***@*****:/home2/**/NLPLearn/codes/chatservice$ pip install fastText
Requirement already satisfied: fastText in /home/***/anaconda3/envs/nlp/lib/python3.7/site-packages (0.9.2)
Requirement already satisfied: setuptools>=0.7.0 in /home/***/anaconda3/envs/nlp/lib/python3.7/site-packages (from fastText) (52.0.0.post20210125)
Requirement already satisfied: pybind11>=2.2 in /home/***/anaconda3/envs/nlp/lib/python3.7/site-packages (from fastText) (2.6.2)
Requirement already satisfied: numpy in /home/***/anaconda3/envs/nlp/lib/python3.7/site-packages (from fastText) (1.19.2)
(nlp) ***@*****:/home2/***/NLPLearn/codes/chatservice$ python test_classify.py
Traceback (most recent call last):
File "test_classify.py", line 4, in <module>
from classify.build_model import prepar_model,test_model
File "/home2/***/NLPLearn/codes/chatservice/classify/build_model.py", line 4, in <module>
import fastText
ModuleNotFoundError: No module named 'fastText'
解决如下:
在fastText==0.9.0以后import时就改为小写。即:
import fastText
# 改为
import fasttext
详情见:https://github.com/facebookresearch/fastText/issues/474