Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.

Install fails: No module named 'pybind11' #512

Closed
DomHudson opened this issue May 7, 2018 · 27 comments
Closed

Install fails: No module named 'pybind11' #512

DomHudson opened this issue May 7, 2018 · 27 comments

Comments

@DomHudson
Copy link

DomHudson commented May 7, 2018

Summary

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:

System

Python 3.6.5 (default, Apr  1 2018, 05:46:30) 
[GCC 7.3.0] on linux
Name: pip
Version: 10.0.1
Distributor ID:	Ubuntu
Description:	Ubuntu 18.04 LTS
Release:	18.04
Codename:	bionic

$ 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('\r\n', '\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

@DomHudson
Copy link
Author

DomHudson commented May 7, 2018

I created an issue upstream in pybind's example project: pybind/python_example#32

EDIT: with a possible solution here

@galogen777
Copy link

i've installed pybind11
pip install pybind11 and all OK

@DomHudson
Copy link
Author

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

@Shubhammawa
Copy link

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

@Shubhammawa
Copy link

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

facebook-github-bot pushed a commit that referenced this issue Nov 27, 2018
Summary: In some environments, `python setup.py install` fails to install pybind11. The solution is given by `pybind11`'s repository which consists on calling `pip install pybind11` via subprocess. The issue and the solution were reported here #512

Reviewed By: EdouardGrave

Differential Revision: D13167381

fbshipit-source-id: 4ee7835a07e503d00728857242e085bc7de53c14
@Celebio
Copy link
Member

Celebio commented Dec 3, 2018

Hi,
We modified the way pybind is imported as you suggested on b8022b5.
Hopefully it would be useful for those having similar issues.

Thank you all for your feedback!

Onur

@Celebio Celebio closed this as completed Dec 3, 2018
@explosiveamber
Copy link

Missing python3-dev on the system is likely to be the source of this problem.

Try, as root: apt install python3-dev

@Midonaga
Copy link

Midonaga commented Dec 6, 2021

Python 3.10.0

Screenshot (86)
I want a help to fix this bug

@shashika18923
Copy link

Python 3.10.0

Screenshot (86) I want a help to fix this bug

did you find any solution i also got this error

@AIGeneratedUsername
Copy link

Running brew install pybind11 and pip install pybind11 does not help. The package still can not be found.

@P0oOOOo0YA
Copy link

@Celebio Can't install fasttest due to pybind11 can't be found issue. I did install pybind11 via poetry but still fasttext installer complains about pybind11. Please take a look at this annoying issue. I'm using python 3.10.6 on manjaro with poetry package manager.

@victorphamdeveloper
Copy link

anyone has any idea how to fix this issue now ?

@AIGeneratedUsername
Copy link

AIGeneratedUsername commented Nov 8, 2022

anyone has any idea how to fix this issue now ?

@victorphamdeveloper I solved the problem by switching to pip install fasttext-wheel. Installation works fine in my Docker image based on python:3.10.6-slim-bullseye.

@ZJaume
Copy link

ZJaume commented May 4, 2023

Latest PIP seems to not use legacy build anymore. Adding a pyproject.toml with dependencies like #1292, solves the issue. For anyone who fasttext-wheel does not work,

pip install git+https://github.com/cfculhane/fastText

or

poetry add git+https://github.com/cfculhane/fastText#main

for those who use poetry, might work.

@Fohlen
Copy link

Fohlen commented Jun 1, 2023

anyone has any idea how to fix this issue now ?

@victorphamdeveloper I solved the problem by switching to pip install fasttext-wheel. Installation works fine in my Docker image based on python:3.10.6-slim-bullseye.

I was extremely surprised to find that wheels aren't build for fasttext by default. It is rather bad practice to install python-dev (in production environments). As fasttext-wheel is MIT licensed and openly available, it's something that could be adopted with ease. Is there any interest? I'm sure we can create a MR if necessary :)

@zhangza20
Copy link

@Celebio Can't install fasttest due to pybind11 can't be found issue. I did install pybind11 via poetry but still fasttext installer complains about pybind11. Please take a look at this annoying issue. I'm using python 3.10.6 on manjaro with poetry package manager.

Actually you just need to find the fasttext.whl and download it, after entering the address of the whl you execute "pip install fasttext-xxx.whl then it will install fasttext on your equipment. At least it works on my computer.

@hoooy202
Copy link

same problem...!!! non of above works! what should i do???

@hoooy202
Copy link

i downloaded fasttext from this address and i installed with pip install
https://www.lfd.uci.edu/~gohlke/pythonlibs/#fasttext
Worked!

@Karimai
Copy link

Karimai commented Jul 19, 2023

My fastapi project works fine locally. However, I have the same error when I run docker build . command.

pyproject.toml
[tool.poetry.dependencies] python = "^3.11" fastapi = "^0.96.0" uvicorn = "^0.22.0" pybind11 = "^2.11.1" matplotlib = "^3.7.2" jinja2 = "^3.1.2"
File "/tmp/tmptf7q1ede/matplotlib-3.7.2/setupext.py", line 19, in
from pybind11.setup_helpers import Pybind11Extension
ModuleNotFoundError: No module named 'pybind11'

@david-waterworth
Copy link

@Karimai have you tried the option mentioned above?

poetry add git+https://github.com/cfculhane/fastText#main

Note this installs the latest commit (0.9.2 4a44513), you may need to find the commit for the specific version you need.

@brondsem
Copy link

Run pip install wheel before installing fasttext worked for me.

Because pip 23.1 changed its build behavior when wheel package is not present. https://pip.pypa.io/en/latest/news/#v23-1

@sigridjineth
Copy link

@brondsem you saved my life - thks

@sherlockyb
Copy link

@brondsem
This worked for me, many thanks.

@tf13
Copy link

tf13 commented Oct 18, 2023

Run pip install wheel before installing fasttext worked for me.

Because pip 23.1 changed its build behavior when wheel package is not present. https://pip.pypa.io/en/latest/news/#v23-1

This worked for me in python 3.11.5, but not in 3.12.0 for some reason.

@gndps
Copy link

gndps commented Dec 3, 2023

pybind11 was already installed. Fasttext installation was not able to find pybind11 until I ran this:

pip install wheel setuptools pip --upgrade

@RubTalha
Copy link

RubTalha commented Dec 9, 2023

https://stackoverflow.com/a/77630437/13086128

@JuhaKalevi
Copy link

Problem was GCC version 13 for me. It finally worked with CC=gcc-12 pip install fasttext.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests