facebookresearch / fastText

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

Installing fastText on Windows fails with C++ errors #1277

Open moonman239 opened 2 years ago

moonman239 commented 2 years ago

I just followed the instructions to build and install the Python module (https://fasttext.cc/docs/en/support.html) and the installation fails with C++ errors:

`C:\Users\moonman239\fastText>pip install . WARNING: Ignoring invalid distribution -ip (c:\python310\lib\site-packages) WARNING: Ignoring invalid distribution -ip (c:\python310\lib\site-packages) Processing c:\users\moonman239\fasttext Preparing metadata (setup.py) ... done Requirement already satisfied: pybind11>=2.2 in c:\python310\lib\site-packages (from fasttext==0.9.2) (2.9.2) Requirement already satisfied: setuptools>=0.7.0 in c:\python310\lib\site-packages (from fasttext==0.9.2) (58.1.0) Requirement already satisfied: numpy in c:\python310\lib\site-packages (from fasttext==0.9.2) (1.22.3) Building wheels for collected packages: fasttext Building wheel for fasttext (setup.py) ... error error: subprocess-exited-with-error

× python setup.py bdist_wheel did not run successfully. │ exit code: 1 ╰─> [33 lines of output] C:\Python310\lib\site-packages\setuptools\dist.py:717: UserWarning: Usage of dash-separated 'description-file' will not be supported in future versions. Please use the underscore name 'description_file' instead warnings.warn( running bdist_wheel running build running build_py running build_ext building 'fasttext_pybind' extension C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -IC:\Python310\lib\site-packages\pybind11\include -IC:\Python310\lib\site-packages\pybind11\include -Isrc -IC:\Python310\include -IC:\Python310\Include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\include -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\winrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\cppwinrt /EHsc /Tppython/fasttext_module/fasttext/pybind/fasttext_pybind.cc /Fobuild\temp.win-amd64-3.10\Release\python/fasttext_module/fasttext/pybind/fasttext_pybind.obj /EHsc /DVERSION_INFO=\"0.9.2\" fasttext_pybind.cc python/fasttext_module/fasttext/pybind/fasttext_pybind.cc(171): error C2065: 'ssize_t': undeclared identifier python/fasttext_module/fasttext/pybind/fasttext_pybind.cc(171): error C2672: 'pybind11::init': no matching overloaded function found python/fasttext_module/fasttext/pybind/fasttext_pybind.cc(170): error C2974: 'pybind11::init': invalid template argument for 'CFunc', type expected C:\Python310\lib\site-packages\pybind11\include\pybind11\pybind11.h(1920): note: see declaration of 'pybind11::init' python/fasttext_module/fasttext/pybind/fasttext_pybind.cc(170): error C2974: 'pybind11::init': invalid template argument for 'Func', type expected C:\Python310\lib\site-packages\pybind11\include\pybind11\pybind11.h(1912): note: see declaration of 'pybind11::init' python/fasttext_module/fasttext/pybind/fasttext_pybind.cc(170): error C2974: 'pybind11::init': invalid template argument for 'Args', type expected C:\Python310\lib\site-packages\pybind11\include\pybind11\pybind11.h(1900): note: see declaration of 'pybind11::init' python/fasttext_module/fasttext/pybind/fasttextpybind.cc(171): error C2672: 'pybind11::class::def': no matching overloaded function found python/fasttext_module/fasttext/pybind/fasttextpybind.cc(170): error C2780: 'pybind11::class &pybind11::class::def(const char *,Func &&,const Extra &...)': expects 3 arguments - 1 provided C:\Python310\lib\site-packages\pybind11\include\pybind11\pybind11.h(1577): note: see declaration of 'pybind11::class::def' python/fasttext_module/fasttext/pybind/fasttext_pybind.cc(185): error C2065: 'ssize_t': undeclared identifier python/fasttext_module/fasttext/pybind/fasttext_pybind.cc(185): error C2065: 'ssize_t': undeclared identifier python/fasttext_module/fasttext/pybind/fasttext_pybind.cc(185): error C2672: 'pybind11::init': no matching overloaded function found python/fasttext_module/fasttext/pybind/fasttext_pybind.cc(182): error C2974: 'pybind11::init': invalid template argument for 'CFunc', type expected C:\Python310\lib\site-packages\pybind11\include\pybind11\pybind11.h(1920): note: see declaration of 'pybind11::init' python/fasttext_module/fasttext/pybind/fasttext_pybind.cc(182): error C2974: 'pybind11::init': invalid template argument for 'Func', type expected C:\Python310\lib\site-packages\pybind11\include\pybind11\pybind11.h(1912): note: see declaration of 'pybind11::init' python/fasttext_module/fasttext/pybind/fasttext_pybind.cc(182): error C2974: 'pybind11::init': invalid template argument for 'Args', type expected C:\Python310\lib\site-packages\pybind11\include\pybind11\pybind11.h(1900): note: see declaration of 'pybind11::init' python/fasttext_module/fasttext/pybind/fasttextpybind.cc(185): error C2672: 'pybind11::class::def': no matching overloaded function found python/fasttext_module/fasttext/pybind/fasttextpybind.cc(182): error C2780: 'pybind11::class &pybind11::class::def(const char *,Func &&,const Extra &...)': expects 3 arguments - 1 provided C:\Python310\lib\site-packages\pybind11\include\pybind11\pybind11.h(1577): note: see declaration of 'pybind11::class::def' error: command 'C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\bin\HostX86\x64\cl.exe' failed with exit code 2 [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for fasttext Running setup.py clean for fasttext Failed to build fasttext WARNING: Ignoring invalid distribution -ip (c:\python310\lib\site-packages) Installing collected packages: fasttext Running setup.py install for fasttext ... error error: subprocess-exited-with-error

× Running setup.py install for fasttext did not run successfully. │ exit code: 1 ╰─> [52 lines of output] C:\Python310\lib\site-packages\setuptools\dist.py:717: UserWarning: Usage of dash-separated 'description-file' will not be supported in future versions. Please use the underscore name 'description_file' instead warnings.warn( running install running build running build_py creating build creating build\lib.win-amd64-3.10 creating build\lib.win-amd64-3.10\fasttext copying python\fasttext_module\fasttext\FastText.py -> build\lib.win-amd64-3.10\fasttext copying python\fasttext_module\fasttext__init.py -> build\lib.win-amd64-3.10\fasttext creating build\lib.win-amd64-3.10\fasttext\util copying python\fasttext_module\fasttext\util\util.py -> build\lib.win-amd64-3.10\fasttext\util copying python\fasttext_module\fasttext\util__init__.py -> build\lib.win-amd64-3.10\fasttext\util creating build\lib.win-amd64-3.10\fasttext\tests copying python\fasttext_module\fasttext\tests\test_configurations.py -> build\lib.win-amd64-3.10\fasttext\tests copying python\fasttext_module\fasttext\tests\test_script.py -> build\lib.win-amd64-3.10\fasttext\tests copying python\fasttext_module\fasttext\tests\init__.py -> build\lib.win-amd64-3.10\fasttext\tests running build_ext building 'fasttext_pybind' extension creating build\temp.win-amd64-3.10 creating build\temp.win-amd64-3.10\Release creating build\temp.win-amd64-3.10\Release\python creating build\temp.win-amd64-3.10\Release\python\fasttext_module creating build\temp.win-amd64-3.10\Release\python\fasttext_module\fasttext creating build\temp.win-amd64-3.10\Release\python\fasttext_module\fasttext\pybind creating build\temp.win-amd64-3.10\Release\src C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -IC:\Python310\lib\site-packages\pybind11\include -IC:\Python310\lib\site-packages\pybind11\include -Isrc -IC:\Python310\include -IC:\Python310\Include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\include -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\winrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\cppwinrt /EHsc /Tppython/fasttext_module/fasttext/pybind/fasttext_pybind.cc /Fobuild\temp.win-amd64-3.10\Release\python/fasttext_module/fasttext/pybind/fasttext_pybind.obj /EHsc /DVERSION_INFO=\"0.9.2\" fasttext_pybind.cc python/fasttext_module/fasttext/pybind/fasttext_pybind.cc(171): error C2065: 'ssize_t': undeclared identifier python/fasttext_module/fasttext/pybind/fasttext_pybind.cc(171): error C2672: 'pybind11::init': no matching overloaded function found python/fasttext_module/fasttext/pybind/fasttext_pybind.cc(170): error C2974: 'pybind11::init': invalid template argument for 'CFunc', type expected C:\Python310\lib\site-packages\pybind11\include\pybind11\pybind11.h(1920): note: see declaration of 'pybind11::init' python/fasttext_module/fasttext/pybind/fasttext_pybind.cc(170): error C2974: 'pybind11::init': invalid template argument for 'Func', type expected C:\Python310\lib\site-packages\pybind11\include\pybind11\pybind11.h(1912): note: see declaration of 'pybind11::init' python/fasttext_module/fasttext/pybind/fasttext_pybind.cc(170): error C2974: 'pybind11::init': invalid template argument for 'Args', type expected C:\Python310\lib\site-packages\pybind11\include\pybind11\pybind11.h(1900): note: see declaration of 'pybind11::init' python/fasttext_module/fasttext/pybind/fasttextpybind.cc(171): error C2672: 'pybind11::class::def': no matching overloaded function found python/fasttext_module/fasttext/pybind/fasttextpybind.cc(170): error C2780: 'pybind11::class &pybind11::class::def(const char *,Func &&,const Extra &...)': expects 3 arguments - 1 provided C:\Python310\lib\site-packages\pybind11\include\pybind11\pybind11.h(1577): note: see declaration of 'pybind11::class::def' python/fasttext_module/fasttext/pybind/fasttext_pybind.cc(185): error C2065: 'ssize_t': undeclared identifier python/fasttext_module/fasttext/pybind/fasttext_pybind.cc(185): error C2065: 'ssize_t': undeclared identifier python/fasttext_module/fasttext/pybind/fasttext_pybind.cc(185): error C2672: 'pybind11::init': no matching overloaded function found python/fasttext_module/fasttext/pybind/fasttext_pybind.cc(182): error C2974: 'pybind11::init': invalid template argument for 'CFunc', type expected C:\Python310\lib\site-packages\pybind11\include\pybind11\pybind11.h(1920): note: see declaration of 'pybind11::init' python/fasttext_module/fasttext/pybind/fasttext_pybind.cc(182): error C2974: 'pybind11::init': invalid template argument for 'Func', type expected C:\Python310\lib\site-packages\pybind11\include\pybind11\pybind11.h(1912): note: see declaration of 'pybind11::init' python/fasttext_module/fasttext/pybind/fasttext_pybind.cc(182): error C2974: 'pybind11::init': invalid template argument for 'Args', type expected C:\Python310\lib\site-packages\pybind11\include\pybind11\pybind11.h(1900): note: see declaration of 'pybind11::init' python/fasttext_module/fasttext/pybind/fasttextpybind.cc(185): error C2672: 'pybind11::class::def': no matching overloaded function found python/fasttext_module/fasttext/pybind/fasttextpybind.cc(182): error C2780: 'pybind11::class &pybind11::class::def(const char *,Func &&,const Extra &...)': expects 3 arguments - 1 provided C:\Python310\lib\site-packages\pybind11\include\pybind11\pybind11.h(1577): note: see declaration of 'pybind11::class::def' error: command 'C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\bin\HostX86\x64\cl.exe' failed with exit code 2 [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip. error: legacy-install-failure

× Encountered error while trying to install package. ╰─> fasttext

note: This is an issue with the package mentioned above, not pip. hint: See above for output from the failure. WARNING: Ignoring invalid distribution -ip (c:\python310\lib\site-packages) WARNING: Ignoring invalid distribution -ip (c:\python310\lib\site-packages) WARNING: Ignoring invalid distribution -ip (c:\python310\lib\site-packages)

`

suzana-rita commented 2 years ago

I also have the same problem. Then, I tried to install gensim to see if I could even load the Japanese pretrained model for fasttext, but it brings me other problems. If you are dealing with english language, try to use gensim, it might work. See this link.

moonman239 commented 2 years ago

@suzana-rita someone told me about spaCy and that's what I use now.

Atlogit commented 2 years ago

It also occurs when trying to install other packages that have fasttext as dependency. This is a real showstopper issue.

arc12 commented 1 year ago

It is evident from multiple sources on the web that building or installing the fasttext python wrapper on Windows is very problematical for many people, with multiple issues being seen over the years.

Please can this be tidied up and properly documented AND please can install/build on Windows be part of continuous testing.

YanJiangJerry commented 1 year ago

yes

ht21992 commented 9 months ago

I have encountered the same error and solved it as follows:

download fasttext wheel from: https://www.lfd.uci.edu/~gohlke/pythonlibs/#fasttext

(in my case : fasttext-0.9.2-cp39-cp39-win_amd64.whl)

then :

pip install fasttext-0.9.2-cp39-cp39-win_amd64.whl

SaldanhaAJ commented 7 months ago

@ht21992 thanks for your suggestion - How do you determine which wheel to attempt; I keep getting the following errors. TIA

ERROR: fasttext-0.9.2-cp39-cp39-win_amd64.whl is not a supported wheel on this platform.

(base) c:\GitPublic>pip install fasttext-0.9.2-pp38-pypy38_pp73-win_amd64.whl ERROR: fasttext-0.9.2-pp38-pypy38_pp73-win_amd64.whl is not a supported wheel on this platform.

(base) c:\GitPublic>pip install fasttext-0.9.2-cp39-cp39-win32 ERROR: Could not find a version that satisfies the requirement fasttext-0.9.2-cp39-cp39-win32 (from versions: none) ERROR: No matching distribution found for fasttext-0.9.2-cp39-cp39-win32

ht21992 commented 7 months ago

@SaldanhaAJ

fasttext-0.9.2: This is the version of the FastText library. cp39-cp39: This indicates that the wheel is built for Python version 3.9. win_amd64: This indicates that the wheel is built for the Windows 64-bit architecture.

To resolve this issue you must check Python Version and Architecture. If you are using a 32-bit Python, you will need to find a wheel built for a 32-bit architecture

SaldanhaAJ commented 7 months ago

@SaldanhaAJ

fasttext-0.9.2: This is the version of the FastText library. cp39-cp39: This indicates that the wheel is built for Python version 3.9. win_amd64: This indicates that the wheel is built for the Windows 64-bit architecture.

To resolve this issue you must check Python Version and Architecture. If you are using a 32-bit Python, you will need to find a wheel built for a 32-bit architecture

@ht21992 - Thank you for the feedback

simonstey commented 6 months ago

I have encountered the same error and solved it as follows:

download fasttext wheel from: lfd.uci.edu/~gohlke/pythonlibs/#fasttext

(in my case : fasttext-0.9.2-cp39-cp39-win_amd64.whl)

then :

pip install fasttext-0.9.2-cp39-cp39-win_amd64.whl

Since the links seem to be down as of today, here's a zipped version of the wheel for Windows and python 3.11, I found

fasttext-0.9.2-cp311-cp311-win_amd64.whl.zip