Fasttext: Python fasttext build failure

Created on 15 Jan 2018  路  3Comments  路  Source: facebookresearch/fastText

I executed python setup.py install but it is failing with these errors:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.12.25827\Include\numeric(13): note: see declaration of 'std' src\productquantizer.cc(132): error C3861: 'to_string': identifier not found src\productquantizer.cc(132): error C2512: 'std::invalid_argument': no appropriate default constructor available src\productquantizer.cc(132): note: No constructor could take the source type, or constructor overload resolution was ambiguous error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Enterprise\\VC\\Tools\\MSVC\\14.12.25827\\bin\\HostX64\\x64\\cl.exe' failed with exit status 2

I am running Python 3.6.2 :: Anaconda custom (64-bit) on Windows 10 desktop. Do I need specific version of visual studio or build tools?

Build Python

Most helpful comment

First add #include <string> in src\productquantizer.cc, after that you will probably get LNK1104: can not open file 'pthread.lib' error. To resolve this remove -pthread flag from extra_compile_args in setup.py L62. Now simple pip install . will work just fine (I'm on Windows 10, VS Community 2017 and Python 3.6.3 | Anaconda custom (64-bit))

C:\Users\Saad\Desktop\fastText>pip install .
Processing c:\users\saad\desktop\fasttext
Collecting pybind11>=2.2 (from fasttext==0.8.22)
  Using cached pybind11-2.2.1-py2.py3-none-any.whl
Requirement already satisfied: setuptools>=0.7.0 in c:\users\saad\anaconda3\lib\site-packages (from fasttext==0.8.22)
Requirement already satisfied: numpy in c:\users\saad\anaconda3\lib\site-packages (from fasttext==0.8.22)
Installing collected packages: pybind11, fasttext
  Running setup.py install for fasttext ... done
Successfully installed fasttext-0.8.22 pybind11-2.2.1

for more details you can check out discussion at #39.

All 3 comments

First add #include <string> in src\productquantizer.cc, after that you will probably get LNK1104: can not open file 'pthread.lib' error. To resolve this remove -pthread flag from extra_compile_args in setup.py L62. Now simple pip install . will work just fine (I'm on Windows 10, VS Community 2017 and Python 3.6.3 | Anaconda custom (64-bit))

C:\Users\Saad\Desktop\fastText>pip install .
Processing c:\users\saad\desktop\fasttext
Collecting pybind11>=2.2 (from fasttext==0.8.22)
  Using cached pybind11-2.2.1-py2.py3-none-any.whl
Requirement already satisfied: setuptools>=0.7.0 in c:\users\saad\anaconda3\lib\site-packages (from fasttext==0.8.22)
Requirement already satisfied: numpy in c:\users\saad\anaconda3\lib\site-packages (from fasttext==0.8.22)
Installing collected packages: pybind11, fasttext
  Running setup.py install for fasttext ... done
Successfully installed fasttext-0.8.22 pybind11-2.2.1

for more details you can check out discussion at #39.

Thanks @suamin adding #include <string> worked. I don't know how they missed it.

Getting this error while installing fasttext

**pip install fasttext
Collecting fasttext
Using cached fasttext-0.9.1.tar.gz (57 kB)
Requirement already satisfied: pybind11>=2.2 in c:\users\prapt\appdata\local\programs\python\python37-32\lib\site-packages (from fasttext) (2.5.0)
Requirement already satisfied: setuptools>=0.7.0 in c:\users\prapt\appdata\local\programs\python\python37-32\lib\site-packages (from fasttext) (39.0.1)
Requirement already satisfied: numpy in c:\users\prapt\appdata\local\programs\python\python37-32\lib\site-packages (from fasttext) (1.18.1)
Building wheels for collected packages: fasttext
Building wheel for fasttext (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: 'c:\users\prapt\appdata\local\programs\python\python37-32\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\prapt\AppData\Local\Temp\pip-install-z_3utzu4\fasttext\setup.py'"'"'; __file__='"'"'C:\Users\prapt\AppData\Local\Temp\pip-install-z_3utzu4\fasttext\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\prapt\AppData\Local\Temp\pip-wheel-by1e3xjw'
cwd: C:\Users\prapt\AppData\Local\Temp\pip-install-z_3utzu4\fasttext\
Complete output (19 lines):
running bdist_wheel
running build
running build_py
creating build
creating build\lib.win32-3.7
creating build\lib.win32-3.7\fasttext
copying python\fasttext_module\fasttext\FastText.py -> build\lib.win32-3.7\fasttext
copying python\fasttext_module\fasttext__init__.py -> build\lib.win32-3.7\fasttext
creating build\lib.win32-3.7\fasttext\util
copying python\fasttext_module\fasttext\util\util.py -> build\lib.win32-3.7\fasttext\util
copying python\fasttext_module\fasttext\util__init__.py -> build\lib.win32-3.7\fasttext\util
creating build\lib.win32-3.7\fasttext\tests
copying python\fasttext_module\fasttext\tests\test_configurations.py -> build\lib.win32-3.7\fasttext\tests
copying python\fasttext_module\fasttext\tests\test_script.py -> build\lib.win32-3.7\fasttext\tests
copying python\fasttext_module\fasttext\tests__init__.py -> build\lib.win32-3.7\fasttext\tests
running build_ext
building 'fasttext_pybind' extension
b'\\x00C\x00o\x00m\x00m\x00o\x00n\x00 \x00w\x00a\x00s\x00 \x00u\x00n\x00e\x00x\x00p\x00e\x00c\x00t\x00e\x00d\x00 \x00a\x00t\x00 \x00t\x00h\x00i\x00s\x00 \x00t\x00i\x00m\x00e\x00.\x00\r\x00\n\x00'
error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools


ERROR: Failed building wheel for fasttext
Running setup.py clean for fasttext
Failed to build fasttext
Installing collected packages: fasttext
Running setup.py install for fasttext ... error
ERROR: Command errored out with exit status 1:
command: 'c:\users\prapt\appdata\local\programs\python\python37-32\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\prapt\AppData\Local\Temp\pip-install-z_3utzu4\fasttext\setup.py'"'"'; __file__='"'"'C:\Users\prapt\AppData\Local\Temp\pip-install-z_3utzu4\fasttext\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\prapt\AppData\Local\Temp\pip-record-3c4fboc0\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\prapt\appdata\local\programs\python\python37-32\Include\fasttext'
cwd: C:\Users\prapt\AppData\Local\Temp\pip-install-z_3utzu4\fasttext\
Complete output (19 lines):
running install
running build
running build_py
creating build
creating build\lib.win32-3.7
creating build\lib.win32-3.7\fasttext
copying python\fasttext_module\fasttext\FastText.py -> build\lib.win32-3.7\fasttext
copying python\fasttext_module\fasttext__init__.py -> build\lib.win32-3.7\fasttext
creating build\lib.win32-3.7\fasttext\util
copying python\fasttext_module\fasttext\util\util.py -> build\lib.win32-3.7\fasttext\util
copying python\fasttext_module\fasttext\util__init__.py -> build\lib.win32-3.7\fasttext\util
creating build\lib.win32-3.7\fasttext\tests
copying python\fasttext_module\fasttext\tests\test_configurations.py -> build\lib.win32-3.7\fasttext\tests
copying python\fasttext_module\fasttext\tests\test_script.py -> build\lib.win32-3.7\fasttext\tests
copying python\fasttext_module\fasttext\tests__init__.py -> build\lib.win32-3.7\fasttext\tests
running build_ext
building 'fasttext_pybind' extension
b'\\x00C\x00o\x00m\x00m\x00o\x00n\x00 \x00w\x00a\x00s\x00 \x00u\x00n\x00e\x00x\x00p\x00e\x00c\x00t\x00e\x00d\x00 \x00a\x00t\x00 \x00t\x00h\x00i\x00s\x00 \x00t\x00i\x00m\x00e\x00.\x00\r\x00\n\x00'
error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools
----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\users\prapt\appdata\local\programs\python\python37-32\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\prapt\AppData\Local\Temp\pip-install-z_3utzu4\fasttext\setup.py'"'"'; __file__='"'"'C:\Users\prapt\AppData\Local\Temp\pip-install-z_3utzu4\fasttext\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\prapt\AppData\Local\Temp\pip-record-3c4fboc0\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\prapt\appdata\local\programs\python\python37-32\Include\fasttext' Check the logs for full command output.**

Was this page helpful?
0 / 5 - 0 ratings