Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src/twisted/test/raiser.c:4:20: fatal error: Python.h: No such file or directory #668

Closed
adamziaja opened this issue Jan 27, 2018 · 14 comments
Labels

Comments

@adamziaja
Copy link

adamziaja commented Jan 27, 2018

Installation step 4:

    copying src/twisted/internet/test/_awaittests.py.3only -> build/lib.linux-x86_64-3.5/twisted/internet/test
    copying src/twisted/internet/test/_yieldfromtests.py.3only -> build/lib.linux-x86_64-3.5/twisted/internet/test
    creating build/lib.linux-x86_64-3.5/twisted/internet/test/fake_CAs
    copying src/twisted/internet/test/fake_CAs/chain.pem -> build/lib.linux-x86_64-3.5/twisted/internet/test/fake_CAs
    copying src/twisted/internet/test/fake_CAs/not-a-certificate -> build/lib.linux-x86_64-3.5/twisted/internet/test/fake_CAs
    copying src/twisted/internet/test/fake_CAs/thing1.pem -> build/lib.linux-x86_64-3.5/twisted/internet/test/fake_CAs
    copying src/twisted/internet/test/fake_CAs/thing2-duplicate.pem -> build/lib.linux-x86_64-3.5/twisted/internet/test/fake_CAs
    copying src/twisted/internet/test/fake_CAs/thing2.pem -> build/lib.linux-x86_64-3.5/twisted/internet/test/fake_CAs
    copying src/twisted/python/test/_deprecatetests.py.3only -> build/lib.linux-x86_64-3.5/twisted/python/test
    copying src/twisted/words/xish/xpathparser.g -> build/lib.linux-x86_64-3.5/twisted/words/xish
    copying src/twisted/words/im/instancemessenger.glade -> build/lib.linux-x86_64-3.5/twisted/words/im
    copying src/twisted/mail/test/rfc822.message -> build/lib.linux-x86_64-3.5/twisted/mail/test
    running build_ext
    building 'twisted.test.raiser' extension
    creating build/temp.linux-x86_64-3.5
    creating build/temp.linux-x86_64-3.5/src
    creating build/temp.linux-x86_64-3.5/src/twisted
    creating build/temp.linux-x86_64-3.5/src/twisted/test
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.5-MLq5fN/python3.5-3.5.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.5m -I/home/cowrie/cowrie/cowrie-env/include/python3.5m -c src/twisted/test/raiser.c -o build/temp.linux-x86_64-3.5/src/twisted/test/raiser.o
    src/twisted/test/raiser.c:4:20: fatal error: Python.h: No such file or directory
     #include "Python.h"
                        ^
    compilation terminated.
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
    
    ----------------------------------------
Command "/home/cowrie/cowrie/cowrie-env/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-htfbgi5u/twisted/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-r7c_do5e-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/cowrie/cowrie/cowrie-env/include/site/python3.5/twisted" failed with error code 1 in /tmp/pip-build-htfbgi5u/twisted/
(cowrie-env) cowrie@debian-s-1vcpu-1gb-lon1-01:~/cowrie$ 

Debian GNU/Linux 9.3 (stretch)

@fe7ch
Copy link
Contributor

fe7ch commented Jan 27, 2018

Probably, you need python3-dev package.

@micheloosterhof
Copy link
Member

What platform are you building on? Normally Twisted binaries will just be downloaded, in your case it appears to be compiling.

@asenov
Copy link

asenov commented Mar 3, 2018

I've got the same error on CentOS, with included python-devel package:

gcc -pthread -Wno-unused-result -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/home/tim/work/twisted/env/include -I/usr/include/python3.4m -c src/twisted/test/raiser.c -o build/temp.linux-x86_64-3.4/src/twisted/test/raiser.o src/twisted/test/raiser.c:4:20: fatal error: Python.h: No such file or directory #include "Python.h" ^ compilation terminated. error: command 'gcc' failed with exit status 1

@micheloosterhof
Copy link
Member

micheloosterhof commented Mar 4, 2018

You seem to be running a 3.5 Python and probably intalled a 2.7 Python development environment.

For now it's best to run on Python 2 (Python 3 mostly works but not completely yet)

Remove your virtual environment and create a new one using Python 2 like this:

virtualenv -p python2 cowrie-env

Then repeat the steps.

@yeszao
Copy link

yeszao commented May 18, 2018

Maybe you need install python dev first, In ubuntu:

apt install python3-dev

@mTuseeq
Copy link

mTuseeq commented Aug 30, 2018

i faced same problem when installing scrapy on ubuntu, i tried changing version of twisted and it worked for me.

@this-is-r-gaurav
Copy link

What version you used for twisted? I am facing same issue it is perfectly installing globaly but with virtualenv its creating problem

@micheloosterhof
Copy link
Member

The INSTALLmd should work if you follow the steps precisely.
If you get into issues, please let me know and we'll try to update it to be more accurate.

@micheloosterhof
Copy link
Member

For the Python dependencies, the INSTALL.md states:
sudo apt-get install git python-virtualenv libssl-dev libffi-dev build-essential libpython-dev python2.7-minimal authbind
Did you run this and does it work? This will install Py2 dependencies btw.

@micheloosterhof
Copy link
Member

Ah! I see there's a mismatch now, later in the README it suggests a Python3 virtual environment.
This does need to be fixed.

@this-is-r-gaurav
Copy link

Yup I am using Python3

@micheloosterhof
Copy link
Member

I've added a new line to INSTALL.md to document Python3 dependencies. Could you give that a try, please?

@Huge
Copy link

Huge commented Dec 5, 2018

Could be caused when installing in venv for python3.6, although I'm on an older system with python3 being 3.4, although python3-dev is installed for it? I can't think of any solution then.

@cvnli
Copy link

cvnli commented Apr 29, 2019

Maybe you need install python dev first, In ubuntu:

apt install python3-dev

it works

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

No branches or pull requests

9 participants