0

While trying to install modwisgi-3.4 I was getting the following error during make: mod_wsgi.c:142:20: error: Python.h: No such file or directory The official troubleshoot page http://code.google.com/p/modwsgi/wiki/InstallationIssues suggests to "install the developer package for Python corresponding to the Python runtime package you have installed".

Now how to install the mentioned development package from source? I am running python2.7.4 on linux with httpd-2.2.24 and modwisgi 3.4.

6
  • You need your distributions python development package. Is it a Redhat (Fedora/CentOS) or Debian based (Ubuntu/Mint) machine? Commented Jul 3, 2013 at 13:46
  • 1
    yum install python-devel Commented Jul 3, 2013 at 13:50
  • that is not helping.. My problem is that I cannot use yum. Commented Jul 3, 2013 at 13:52
  • Why can't you use yum? If you installed python form source, you should have the needed include files on the system. If you search the system for Python.h; can you find it? Where is it? Commented Jul 3, 2013 at 13:53
  • @tMC it's possible that he does not have root access on the machine and he installed his own personal copy of Python from source. The package's configure script may then be finding the system Python and not his own. Commented Jul 3, 2013 at 14:06

2 Answers 2

1

Run the following:

$ python-config --cflags

This will give you a list of flags to pass to the compiler to find Python.h:

$ python-config --cflags
-I/usr/include/python3.3m -I/usr/include/python3.3m -Wno-unused-result -DDYNAMIC_ANNOTATIONS_ENABLED=
1 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -march=x86-64 -mtune=generic -O2 -pipe -fstack-pr
otector --param=ssp-buffer-size=4 -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ss
p-buffer-size=4

You'll probably also want to run python-config --ldflags for the necessary linker flags.

If you have multiple versions of Python installed, you can specify, i.e., python2.7-config

Then, I would manually edit the file posix-ap2X.mk.in so that it contains the following:

CFLAGS = @CFLAGS@ $(shell python-config --cflags)
LDFLAGS = @LDFLAGS@ $(shell python-config --ldflags)

The configure.ac Autoconf file tries to figure this stuff out but it seems to do it in a clunky way that is apparently not working for you, so this manual way will hopefully sort things out.

Edit: oh, also, be sure that you use the correct python-config and that you specify which Python interpreter to use as necessary. For example, if you have installed Python from source to some non-standard location while there is another version installed in the usual place, be sure to specify this (i.e use /path/to/my/python-config in the above edits and pass the argument PYTHON=/path/to/my/python to the configure script). In fact, simply specifying the correct Python interpreter might cause the included configure script to do its job correctly.

Sign up to request clarification or add additional context in comments.

3 Comments

The mod_wsgi configure script works this all out for you, you don't need to do that yourself.
Yes, I noticed that eventually as I read through configure.ac some more, hence the final edit. BTW, as I understand it, it is standard to specify the Python interpreter location via the PYTHON variable rather than via a --with-python flag. Also, I recommend checking out GNU pyconfigure for some handy Python Autoconf macros (disclaimer: I'm the pyconfigure maintainer; feel free to contact me directly to continue this discussion, so as not to clutter the question).
Apache configure scripts uses --with to indicate locations of packages to be used with Apache. The script follows that convention. So that is the history of why it is done that way.
0

You must use the --with-python option to mod_wsgi configure to tell it the path to the 'python' binary you installed from source code. It looks like you haven't done that and it is still using the system Python which doesn't have the corresponding dev package installed. Provide the details of the actual 'configure' script command line when you ran it and tell us where your self installed Python actually lives. Also make sure you run 'make distclean' to clear out the results of any old build in case that is confusing things.

7 Comments

Hi Graham, I gave the following command for configure: ./configure --prefix=custom_modwsgi_location --with-apxs=apxs_path_of_custom_apache --with-python=custom_python_path --libdir=lib_path_prefix_used_for_apache
Supply the actual path you are using for --with-python. I want to make sure you are pointing it at the correct thing. If you don't it will fallback to system Python still.
configure commands I used: apache: ./configure --with-included-apr --prefix=$MY_APPS/httpd27 --libdir=$MY_APPS/lib27 --enable-ssl --enable-mods-shared=all --with-mpm=worker modwsgi: ./configure --prefix=$MY_APPS/modwsgi27 --with-apxs=$MY_APPS/httpd27/bin/apxs --with-python=$MY_APPS/python2.7/bin/python --libdir=$MY_APPS/lib27
The --prefix and --libdir options to mod_wsgi configure will not do anything. Now, edit your original question and add what is in the generated Makefile for CPPFLAGS and CFLAGS.
Hi Graham, To start on a clean slate I deleted the httpd and python that I installed and reinstalled them. This time I am getting an error on 'make' itself for modwsgi. The error was /usr/bin/ld: /zyme_shared/zyme_apps/zymenet/dev/python2.7/lib/libpython2.7.a(node.o): relocation R_X86_64_32 against a local symbol' can not be used when making a shared object; recompile with -fPIC /zyme_shared/zyme_apps/zymenet/dev/python2.7/lib/libpython2.7.a: could not read symbols: Bad value collect2: ld returned 1 exit status apxs:Error: Command failed with rc=65536 `.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.