The instructions at https://github.com/facebookresearch/fastText#building-fasttext-for-python do not work for me now. Installing straight from github has the same problem:
Python 3.6.5 (default, Apr 1 2018, 05:46:30)
[GCC 7.3.0] on linux
Name: pip
Version: 10.0.1
md5-0884b744ef7ebb7d442c0f51b32b4a9f
Distributor ID: Ubuntu
Description: Ubuntu 18.04 LTS
Release: 18.04
Codename: bionic
md5-0884b744ef7ebb7d442c0f51b32b4a9f
$ pip install git+https://github.com/facebookresearch/fastText.git
Collecting git+https://github.com/facebookresearch/fastText.git
Cloning https://github.com/facebookresearch/fastText.git to /tmp/pip-req-build-ys1obm8i
Collecting pybind11>=2.2 (from fasttext==0.8.22)
Using cached https://files.pythonhosted.org/packages/12/90/0f92a575dc60c8fba6d0c91d6b45abdb1058da9ebed40400cbcfad2ac0a7/pybind11-2.2.3-py2.py3-none-any.whl
Requirement already satisfied: setuptools>=0.7.0 in ./env/lib/python3.6/site-packages (from fasttext==0.8.22) (39.1.0)
Collecting numpy (from fasttext==0.8.22)
Using cached https://files.pythonhosted.org/packages/71/90/ca61e203e0080a8cef7ac21eca199829fa8d997f7c4da3e985b49d0a107d/numpy-1.14.3-cp36-cp36m-manylinux1_x86_64.whl
Building wheels for collected packages: fasttext
Running setup.py bdist_wheel for fasttext ... error
Complete output from command /home/dom/Code/env/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-req-build-ys1obm8i/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('rn', 'n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/pip-wheel-3tmdz6v7 --python-tag cp36:
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.6
creating build/lib.linux-x86_64-3.6/fastText
copying python/fastText/FastText.py -> build/lib.linux-x86_64-3.6/fastText
copying python/fastText/__init__.py -> build/lib.linux-x86_64-3.6/fastText
creating build/lib.linux-x86_64-3.6/fastText/util
copying python/fastText/util/util.py -> build/lib.linux-x86_64-3.6/fastText/util
copying python/fastText/util/__init__.py -> build/lib.linux-x86_64-3.6/fastText/util
creating build/lib.linux-x86_64-3.6/fastText/tests
copying python/fastText/tests/test_configurations.py -> build/lib.linux-x86_64-3.6/fastText/tests
copying python/fastText/tests/test_script.py -> build/lib.linux-x86_64-3.6/fastText/tests
copying python/fastText/tests/__init__.py -> build/lib.linux-x86_64-3.6/fastText/tests
running build_ext
creating tmp
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.6-EKG1lX/python3.6-3.6.5=. -specs=/usr/share/dpkg/no-pie-compile.specs -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.6m -I/home/dom/Code/env/include/python3.6m -c /tmp/tmpop0x6itb.cpp -o tmp/tmpop0x6itb.o -std=c++14
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.6-EKG1lX/python3.6-3.6.5=. -specs=/usr/share/dpkg/no-pie-compile.specs -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.6m -I/home/dom/Code/env/include/python3.6m -c /tmp/tmp5l3sdeoy.cpp -o tmp/tmp5l3sdeoy.o -fvisibility=hidden
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
building 'fasttext_pybind' extension
Traceback (most recent call last):
File "", line 1, in
File "/tmp/pip-req-build-ys1obm8i/setup.py", line 175, in
zip_safe=False,
File "/home/dom/Code/env/lib/python3.6/site-packages/setuptools/__init__.py", line 129, in setup
return distutils.core.setup(**attrs)
File "/usr/lib/python3.6/distutils/core.py", line 148, in setup
dist.run_commands()
File "/usr/lib/python3.6/distutils/dist.py", line 955, in run_commands
self.run_command(cmd)
File "/usr/lib/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/home/dom/Code/env/lib/python3.6/site-packages/wheel/bdist_wheel.py", line 202, in run
self.run_command('build')
File "/usr/lib/python3.6/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/lib/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/usr/lib/python3.6/distutils/command/build.py", line 135, in run
self.run_command(cmd_name)
File "/usr/lib/python3.6/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/lib/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/home/dom/Code/env/lib/python3.6/site-packages/setuptools/command/build_ext.py", line 78, in run
_build_ext.run(self)
File "/usr/lib/python3.6/distutils/command/build_ext.py", line 339, in run
self.build_extensions()
File "/tmp/pip-req-build-ys1obm8i/setup.py", line 129, in build_extensions
build_ext.build_extensions(self)
File "/usr/lib/python3.6/distutils/command/build_ext.py", line 448, in build_extensions
self._build_extensions_serial()
File "/usr/lib/python3.6/distutils/command/build_ext.py", line 473, in _build_extensions_serial
self.build_extension(ext)
File "/home/dom/Code/env/lib/python3.6/site-packages/setuptools/command/build_ext.py", line 199, in build_extension
_build_ext.build_extension(self, ext)
File "/usr/lib/python3.6/distutils/command/build_ext.py", line 533, in build_extension
depends=ext.depends)
File "/usr/lib/python3.6/distutils/ccompiler.py", line 566, in compile
depends, extra_postargs)
File "/usr/lib/python3.6/distutils/ccompiler.py", line 341, in _setup_compile
pp_opts = gen_preprocess_options(macros, incdirs)
File "/usr/lib/python3.6/distutils/ccompiler.py", line 1075, in gen_preprocess_options
pp_opts.append("-I%s" % dir)
File "/tmp/pip-req-build-ys1obm8i/setup.py", line 37, in __str__
import pybind11
ModuleNotFoundError: No module named 'pybind11'
Failed building wheel for fasttext
Running setup.py clean for fasttext
Failed to build fasttext
Installing collected packages: pybind11, numpy, fasttext
Running setup.py install for fasttext ... done
Successfully installed fasttext-0.8.22 numpy-1.14.3 pybind11-2.2.3
I created an issue upstream in pybind's example project: https://github.com/pybind/python_example/issues/32
EDIT: with a possible solution here
i've installed pybind11
pip install pybind11 and all OK
Hi, thanks - yes that is true thank you.
However, the setup is supposed to install it so that the fastText package can be installed with just setup.py, see here https://github.com/facebookresearch/fastText/blob/master/setup.py#L30
I installed pybind11 using pip install pybind11 - It shows that requirement already satisfied.
Ran this again -
python setup.py install
still the same error comes up
No module named pybind11
I created an issue upstream in pybind's example project: pybind/python_example#32
EDIT: with a possible solution here
This worked for me. Thanks
Hi,
We modified the way pybind is imported as you suggested on b8022b5755e2531c5fe3b4e91dbd4e0025024428.
Hopefully it would be useful for those having similar issues.
Thank you all for your feedback!
Onur
Missing python3-dev on the system is likely to be the source of this problem.
Try, as root: apt install python3-dev
Most helpful comment
i've installed pybind11
pip install pybind11 and all OK