ModuleNotFoundError: No module named 'fasttext'
Asked Answered
A

1

9

I have tried installing fasttext through conda using two channels:

conda install -c conda-forge fasttext

and

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

as per (https://anaconda.org/conda-forge/fasttext).

I am using the following command to import: import fasttext However, the import fails with the error:

ModuleNotFoundError Traceback (most recent call last) in ----> 1 import fasttext

ModuleNotFoundError: No module named 'fasttext'

However, tried to import it in an older fashion import fastText, which failed.

Have tried it on python and python3, both of which fail.

I want to avoid installing it using pip and manage the packages using conda.

conda list shows that fasttext being installed. The output of which is shown below:

fasttext 0.2.0 hfc679d8_1 conda-forge/label/cf201901

The output of python -c 'import sys; print(sys.path) is as below:

['', '/<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']

Astigmia answered 1/10, 2019 at 14:18 Comment(6)
fasttext =/= fastText, so no surprise that failed there. Is there any kind of virtual environment or anything that could be impacting this?Cecilla
What platform you're on? Could you provide the result of which -a python on *nix, where python from cmd.exe on Windows? Could you provide the full conda list output as well?Colored
Sorry, I have edited the question, I have tried importing in both the ways import fasttext and import fastText, both of which fails.Cadastre
which - a python yields: /<dir>/<dir>/anaconda3/bin/python /usr/bin/pythonCadastre
First, just do conda install -c conda-forge fasttext, not both. The additional subchannels (labels) that existing on Anaconda Cloud are usually for very specialized purposes (e.g., alternative build toolchains). Second, from your activated environment, please get the output of python -c 'import sys; print(sys.path) and add it to your question.Nopar
@merv, I have updated the question with whatever you have said.Cadastre
T
6

I used fastText in this way:

!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')

Note 1: Pay attention to uppercase letters.

Note 2: Here is the list of supported languages.

Tansey answered 15/8, 2020 at 21:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.