pythonpython-modulemod-python

got errors when import mod_python


After finishing install mod_python, I got 500 Internal Server Error. I looked up the log, it says: python_handler: Can't get/create interpreter.

Then I open a python terminal and to test if I can import mod_python. Then I got errors as follows:

>>> import mod_python
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/mod_python/__init__.py", line 25, in <module>
    import version
  File "/usr/local/lib/python2.7/dist-packages/mod_python/version.py", line 3
    version = "fatal: Not a git repository (or any of the parent directories): .git
                                                                              ^
SyntaxError: EOL while scanning string literal

I installed mod_python with command --with-python=/usr/bin/python which version is 2.7.3.

Any ideas why this happens? Thanks ahead!

EDIT: I tried to reinstall mod_python with python2.6, I found I missed the SyntaxError posted during installation.

SyntaxError: ('EOL while scanning string literal', ('/usr/local/lib/python2.6/site-packages/mod_python/version.py', 3, 79, 'version = "fatal: Not a git repository (or any of the parent directories): .git\n'))

This error did appear during the installation.


Solution

  • I had the same problem using mod_python-3.5.0. The problem seems to be in the dist/version.sh file which runs git, but since the distribution doesn't have the .git repository structure, the error is generated.

    I fixed version.sh by just replacing the offending line with an empty definition:

    #GIT=`git describe --always`
    GIT=