【发布时间】:2017-07-28 15:29:57
【问题描述】:
请原谅我的新手,但 fasttext 在 python 上不适合我。我正在使用运行 python 3.6 的 anaconda。我的代码如下(只是一个例子):
import fasttext
model = fasttext.load_model('/home/sproc/share/fastText/model.bin')
print(model.words)
这会返回以下错误:
Traceback (most recent call last):
File "/media/sf_VBoxShare/LiClipseWorkspace/test/testpack/fasttext.py", line 1, in <module>
import fasttext
File "/media/sf_VBoxShare/LiClipseWorkspace/test/testpack/fasttext.py", line 3, in <module>
model = fasttext.load_model('/home/sproc/share/fastText/model.bin')
AttributeError: module 'fasttext' has no attribute 'load_model'
在尝试创建词向量时对 cbow 和 skipgram 做同样的事情。我检查了 .../site-packages/fasttext 目录中的 init.py 文件,它导入了上述属性,但它们不是 model.py 模块的一部分。我猜这与共享对象文件有关,但我不确定。任何帮助是极大的赞赏。
【问题讨论】:
-
似乎缺少一些二进制文件
-
@akshay 有什么想法吗?我在
~/share/fasttext下安装了fasttext(可以工作的标准c),我使用pip install fasttext安装了fasttext,所以我不确定可能是什么问题。 -
你在使用 Anaconda。如果是这样,Cython 应该能够编译它。如果没有尝试安装 Anaconda,然后用 pip 重新安装它
-
我确实在使用 Anaconda 并安装了所有这些优点。不完全确定这里发生了什么。
-
将文件名 fasttext.py 更改为其他名称。确保当前目录中没有名为 fasttext.{py,pyc} 的文件