Reputation: 399
I'm trying to install mod_python but I got an error:
SyntaxError: ('EOL while scanning string literal', ('/usr/local/lib/python2.7/dist-packages/mod_python/version.py', 3, 79, 'version = "fatal: Not a git repository (or any of the parent directories): .git\n'))
This is the version.sh file used in mod_python.
#!/bin/sh
MPV_PATH="`dirname $0`/../src/include/mp_version.h"
MAJ=`awk '/MP_VERSION_MAJOR/ {print $3}' $MPV_PATH`
MIN=`awk '/MP_VERSION_MINOR/ {print $3}' $MPV_PATH`
PCH=`awk '/MP_VERSION_PATCH/ {print $3}' $MPV_PATH`
GIT=`git describe --always`
echo $MAJ.$MIN.$PCH-$GIT
I run it manually then I got:
fatal: Not a git repository (or any of the parent directories): .git
3.4.1-
What does this mean? Pleas help!!
Thanks!
Upvotes: 2
Views: 3669
Reputation: 1170
I had the same symptom but in a slightly different environment. This was on Gentoo linux (albeit in 2017 and having not done the big system updates for 1-2 years due to fundamental changes in Gentoo that I was not ready to invest in). Posting here in case it helps someone with the same fundamental problem (as it took me a solid ~3 hours to get it solved).
I installed mod_python (using emerge), restarted Apache service, and added a test python page and navigated to it in a web browser. Here's what I got on the web page:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, ... and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Apache/2.2.31 (Gentoo) DAV/2 mod_ssl/2.2.31 OpenSSL/1.0.2j mod_python/3.5.0- Python/2.7.5 SVN/1.8.14 PHP/5.5.16-pl0-gentoo Server at localhost Port 80
Here's what I found in Apache's error log after installing mod_python and trying to test it:
[Wed Feb 22 11:34:05 2017] [notice] mod_python: Creating 8 session mutexes based on 10 max processes and 1 max threads.
[Wed Feb 22 11:34:05 2017] [notice] mod_python: using mutex_directory /tmp
[Wed Feb 22 11:34:05 2017] [notice] Apache/2.2.31 (Unix) DAV/2 mod_ssl/2.2.31 OpenSSL/1.0.2j mod_python/3.5.0- Python/2.7.5 SVN/1.8.14 PHP/5.5.16-pl0-gentoo configured -- resuming normal operations
[Wed Feb 22 11:34:21 2017] [error] make_obcallback: could not import mod_python.apache.\n
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/mod_python/__init__.py", line 25, in <module>
from . import version
File "/usr/lib/python2.7/site-packages/mod_python/version.py", line 3
version = "fatal: Not a git repository (or any parent up to mount point /var)
^
SyntaxError: EOL while scanning string literal
[Wed Feb 22 11:34:21 2017] [error] make_obcallback: Python path being used "['/usr/lib/python2.7/site-packages/Genshi-0.7-py2.7-linux-i686.egg', '/usr/lib/python2.7/site-packages/Trac-1.2-py2.7.egg', '/usr/lib/python27.zip', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-linux2', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/lib/python2.7/site-packages', '/usr/lib/python2.7/site-packages/gst-0.10', '/usr/lib/python2.7/site-packages/gtk-2.0', '/usr/lib/python2.7/site-packages/wx-2.8-gtk2-unicode']".
[Wed Feb 22 11:34:21 2017] [error] get_interpreter: no interpreter callback found.
So based on the path to the python files it was calling (ex. "/usr/lib/python2.7/site-packages/mod_python/init.py") I could at least confirm that a bunch of stuff was working correctly:
I note these items because between the limited and not entirely descriptive messages (at least to a novice), a lot is left to wonder or piece together.
I finally looked at the actual Python source code for the files in the Traceback
Looking at the actual code in the Traceback (starting with init.py) I see it ended with version = "fatal: Not a git repository ..."
. Looking at this file (version.py) along with an incidental note from some website I think the problem is that the script which generates version.py ("setup.py" according to the header inside version.py) assumed that it was running from a Git clone and reported some fatal error when that was not the case. The script blindly put the error message PLUS the version in the version variable:
version = "fatal: Not a git repository (or any parent up to mount point /var)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
3.5.0-"
So all I had to do was set this variable to a valid value:
version = "3.5.0-"
(NOTE: If you care, the version of mod_python appears to be at the end of the original string.)
Restarted Apache and Python worked fine in my test web page.
Upvotes: 0
Reputation: 9
I use this shell command to patch the Makefile* files and the version.sh file in the root source tree before executing ./configure ... :
sed \
-e 's/(git describe --always)/(git describe --always 2>\/dev\/null)/g' \
-e 's/`git describe --always`/`git describe --always 2>\/dev\/null`/g' \
-i $( find . -type f -name Makefile\* -o -name version.sh )
Upvotes: 0
Reputation: 33063
The version.sh
file assumes you are installing from git. That seems like a bug.
To fix it, you can remove the line
GIT=`git describe --always`
and change the next line to
echo $MAJ.$MIN.$PCH
Upvotes: 7