facebookresearch / fastText

Library for fast text representation and classification.
https://fasttext.cc/
MIT License
25.88k stars 4.71k forks source link

fasttext installed but import fails #474

Closed ahmedahmedov closed 6 years ago

ahmedahmedov commented 6 years ago

Hi have successfully installed fasttext on python3.5. However, when I try to import it I get the following error:

Using /usr/local/lib/python3.5/dist-packages
Finished processing dependencies for fasttext==0.8.22
user@server:~/GitHub/fastText$ python3.5
Python 3.5.2 (default, Nov 23 2017, 16:37:01) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import fasttext
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'fasttext'
>>> 

I have tried installing both with pip install . and python setup.y install with no luck.

ahmedahmedov commented 6 years ago

Oh... so, I need to type fastText and not fasttext...

EdouardGrave commented 6 years ago

Hi @ahmedahmedov,

It seems that this issue is resolved. Please re-open if necessary.

Best, Edouard.

kishore0905 commented 6 years ago

import fastText as Fasttext Traceback (most recent call last): File "", line 1, in ModuleNotFoundError: No module named 'fastText'

though i installed it

lvjiujin commented 6 years ago

I also met the same problem, but how to solve it ? who can help me ? I install fasttext with the following method: pip install fasttext-0.8.22-cp36-cp36m-win_amd64.whl

lvjiujin commented 6 years ago

fastTest,not fasttext

abedkhooli commented 5 years ago

I have 0.8.3 on Win 10 and it imports as fasttext (all lower case). Code seems updated but not docs.

Sharonno commented 5 years ago

Hi have successfully installed fasttext on python3.6 via conda . However, when I try to import it I get the following error: import fasttext neither can be right: import fastText

salehshadi commented 5 years ago

I have the same issue, the strange thing that it was working properly then it stopped without me changing anything in the environment: OS: Ubuntu 18.04.1 LTS (GNU/Linux 4.15.17-1-pve x86_64) python : Python 3.6.3 |Anaconda, Inc.| (default, Oct 13 2017, 12:02:49) I uninstalled fastText and installed again using pip and got "Successfully installed fasttext-0.8.3" however it did not work: Exception: Unable to import fastText. Please install fastText for Python: https://github.com/facebookresearch/fastText

Any feedback?

YiyuJia commented 5 years ago

ModuleNotFoundError Traceback (most recent call last)

in 3 import pandas as pd 4 import numpy as np ----> 5 import fasttext 6 try: 7 from urllib.request import urlopen # For Python 3.0 and later ModuleNotFoundError: No module named 'fasttext' I got same error message. I use below command to install fasttext, conda install cython fasttext
YiyuJia commented 5 years ago

follow below instruction to install successfully

https://github.com/facebookresearch/fastText/tree/master/python

The easiest way to install fastText is to use pip.

$ git clone https://github.com/facebookresearch/fastText.git $ cd fastText $ pip install . Alternatively you can also install fastText using setuptools.

$ git clone https://github.com/facebookresearch/fastText.git $ cd fastText $ python setup.py install Now you can import this library with

import fastText

infinite-Joy commented 5 years ago

@YiyuJia conda installation of fasttext will give an earlier version of fasttext and hence you should install using pip.


Collecting fasttext
  Using cached https://files.pythonhosted.org/packages/a4/86/ff826211bc9e28d4c371668b30b4b2c38a09127e5e73017b1c0cd52f9dfa/fasttext-0.8.3.tar.gz
Requirement already satisfied: numpy>=1 in /Users/joydeep/anaconda3/lib/python3.6/site-packages (from fasttext) (1.14.3)
Collecting future (from fasttext)
  Downloading https://files.pythonhosted.org/packages/90/52/e20466b85000a181e1e144fd8305caf2cf475e2f9674e797b222f8105f5f/future-0.17.1.tar.gz (829kB)
    100% |████████████████████████████████| 829kB 3.5MB/s
Building wheels for collected packages: fasttext, future
  Running setup.py bdist_wheel for fasttext ... done
  Stored in directory: /Users/joydeep/Library/Caches/pip/wheels/73/8e/5d/ecb50b90adaab5868ae1d8df180f31e55e85c2f055aaf2fb35
  Running setup.py bdist_wheel for future ... done
  Stored in directory: /Users/joydeep/Library/Caches/pip/wheels/0c/61/d2/d6b7317325828fbb39ee6ad559dbe4664d0896da4721bf379e
Successfully built fasttext future
distributed 1.21.8 requires msgpack, which is not installed.
Installing collected packages: future, fasttext
Successfully installed fasttext-0.8.3 future-0.17.1
You are using pip version 10.0.1, however version 18.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
$ python
Python 3.6.5 |Anaconda, Inc.| (default, Apr 26 2018, 08:42:37)
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import fasttext
>>>```
cheahengsoon commented 5 years ago

I had try the command

$ git clone https://github.com/facebookresearch/fastText.git
$ cd fastText
$ pip install .

it still can't work. even i change fasttext or fastText also not working.

eadka commented 5 years ago

Kept facing this issue but finally saw that it was failing because of No module named 'pybind11' This resolution helped fix it: https://github.com/pybind/python_example/issues/32#issuecomment-387037509 Able to import fastText into python now.

ParardhaKumar commented 5 years ago

I have the same issue, the strange thing that it was working properly then it stopped without me changing anything in the environment: OS: Ubuntu 18.04.1 LTS (GNU/Linux 4.15.17-1-pve x86_64) python : Python 3.6.3 |Anaconda, Inc.| (default, Oct 13 2017, 12:02:49) I uninstalled fastText and installed again using pip and got "Successfully installed fasttext-0.8.3" however it did not work: Exception: Unable to import fastText. Please install fastText for Python: https://github.com/facebookresearch/fastText

Any feedback?

Try "import fasttext", seems like they haven't updated this in the docs.

hsnzfr commented 5 years ago

I was trying to install fasttext on win 10. The error persisted for two days. Finally I downgraded python for 3.7 to 3.6 and finally is was installed successfully

ConstantSun commented 5 years ago

Oh... so, I need to type fastText and not fasttext...

Finally!! I wonder why in fastText doc they are telling us to type: import fasttext

isyufeng commented 5 years ago

Hi have successfully installed fasttext on python3.6 via conda . However, when I try to import it I get the following error: import fasttext neither can be right: import fastText

I have the same issue, anyone can help...

jikimlucas commented 5 years ago

see the requirement. I faced the same issue basically, it was missing c++ compiler. Then, followed this. https://askubuntu.com/questions/610291/how-to-install-cmake-3-2-on-ubuntu Then, installed fasttext as instructed.

pmeier-tiplu commented 5 years ago

package name is fasttext since 0.9.0

semolnahali commented 4 years ago

if you are importing FastText from Gensim make sure your Gensim version is higher than 3.3

subhash9758964966 commented 4 years ago

I thik your code cannot able find the path. So give path to them or put fastText folder where you written the code.

rastogi-sachin commented 4 years ago

install fasttext using pip. It worked for me in Jupiter notebook. And there is no name change it is "fasttext" only.

Gitanjali1801 commented 3 years ago

change "import fastText as ft" to "import fasttext as ft". Worked for me.

prashantfb65 commented 3 years ago

First things first, check if after successful installation you can see the package installed using pip freeze E.g.

pip freeze | grep fast

Output: fastai==2.5.2 fastapi==0.61.1 fastcore==1.3.26 fastdownload==0.0.5 fastprogress==1.0.0

There is a possibility that installation was done for Python 2 and not Python 3 (as the fasttext documents use sudo to install the package). I found it from one of the log.

Requirement already satisfied (use --upgrade to upgrade): fasttext==0.9.2 from file:///home/prashant/ml_stuff/fastText in /usr/local/lib/python2.7/dist-packages

Try, removing sudo from the pip install command for fasttext to see if that enables the installation for Python3.

Repeat the command again.

pip freeze | grep fast

Output: fastai==2.5.2 fastapi==0.61.1 fastcore==1.3.26 fastdownload==0.0.5 fastprogress==1.0.0 fasttext @ file:///home/prashant/ml_stuff/fastText

And bingo, it worked after that for me.

Type "help", "copyright", "credits" or "license" for more information.
>>> import fasttext
>>>

Note: This might not work for everyone, but surely worked for me.

qqfox commented 3 years ago

oat!!! I tried import fastText but keep getting error until use import fasttext. It works for me.