Vim is 64bit; python 2.7.9 is also 64bit:
===
$ file -L "$(command -v vim)"
/home/marslo/.marslo/myprograms/vim74/bin/vim: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=265c9e9eefa3d0bcebe49011e8115601ae6e85ad, stripped
$ file -L "$(command -v python)"
/usr/local/bin/python: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=cfef76ad27f2141552a72a0d9f6340f0421bdd5b, not stripped
$ python --version
Python 2.7.9
===
From this (https://groups.google.com/forum/#!msg/vim_dev/PkWFDWcg4iI/ymOA2QX1BQAJ) topic. They said the E887 is because of $PYTHONHOME. So I run command in vim:
:let $PYTHONHOME="/usr/local/"
:echo has('python')
1
:python print 'abc'
E887: Sorry, this command is disabled, the Python's site module could not be loaded.
What should I do?
Well, here one thing looks odd, when compile python:
===
$ ./configure --prefix=/usr/local --enable-shared LDFLAGS="-Wl,-rpath /usr/local/lib"
...
checking for --with-cxx-main=<compiler>... no
checking for g++... no
configure: WARNING:
By default, distutils will build C++ extension modules with "g++".
If this is not intended, then set CXX on the configure command line.
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /usr/bin/grep
...
$ rpm -qa | grep gcc-c++
gcc-c++-4.8.5-4.el7.x86_64
=====
2016/1/7 Thu 17:40:38 UTC+9 Marslo Jiao wrote:
> The preinstall (default) and newinstall (2.7.11) are all Py_UNICODE_SIZE == 2
Oh, really? I think it's very strange.
BTW, it's not so important.
The problem is why the Vim's configure script misdetected the python's header
directory. The configure script checks python2 command first, then python
command. If the preinstalled python has python2 command, and if your self-
built python doesn't have python2 command, the misdetection might occur.
Maybe we should use INCLUDEPY variable from <python-config-dir>/Makefile?
E.g.:
--- a/src/configure.in
+++ b/src/configure.in
@@ -1128,6 +1128,7 @@
@echo "python_LINKFORSHARED='$(LINKFORSHARED)'"
@echo "python_DLLLIBRARY='$(DLLLIBRARY)'"
@echo "python_INSTSONAME='$(INSTSONAME)'"
+ @echo "python_INCLUDEPY='$(INCLUDEPY)'"
@echo "python_PYTHONFRAMEWORK='$(PYTHONFRAMEWORK)'"
@echo "python_PYTHONFRAMEWORKPREFIX='$(PYTHONFRAMEWORKPREFIX)'"
@echo "python_PYTHONFRAMEWORKINSTALLDIR='$(PYTHONFRAMEWORKINSTALLDIR)'"
@@ -1182,9 +1183,9 @@
PYTHON_LIBS="${vi_cv_path_python_plibs}"
if test "${vi_cv_path_python_pfx}" = "${vi_cv_path_python_epfx}"; then
- PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version} -DPYTHON_HOME='\"${vi_cv_path_python_pfx}\"'"
+ PYTHON_CFLAGS="-I${python_INCLUDEPY} -I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version} -DPYTHON_HOME='\"${vi_cv_path_python_pfx}\"'"
else
- PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version} -I${vi_cv_path_python_epfx}/include/python${vi_cv_var_python_version} -DPYTHON_HOME='\"${vi_cv_path_python_pfx}\"'"
+ PYTHON_CFLAGS="-I${python_INCLUDEPY} -I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version} -I${vi_cv_path_python_epfx}/include/python${vi_cv_var_python_version} -DPYTHON_HOME='\"${vi_cv_path_python_pfx}\"'"
fi
PYTHON_SRC="if_python.c"
PYTHON_OBJ="objects/if_python.o"
Sorry, this patch is not tested at all.
(Maybe a similar patch for python3 is also needed.)
Regards,
Ken Takata
Hi Ken Takata
Sorry for trouble you again. This error occurred again.
----------------------------
Error is:
The --with-python-config-dir=/usr/local/lib/python2.7/config has been set, but vim/Makefile still use the /usr as the PYTHON_HOME:
gcc -c -I. -Iproto -DHAVE_CONFIG_H -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -I/usr/include/python2.7 -DPYTHON_HOME='"/usr"' -pthread -fPIE -o objects/if_python.o if_python.c
if_python.c:67:20: fatal error: Python.h: No such file or directory
#include <Python.h>
^
compilation terminated.
make[1]: *** [objects/if_python.o] Error 1
make[1]: Leaving directory `/home/marslo/.vim/vimsrc/src'
make: *** [first] Error 2
----------------------
The following is the part of compiled log (full log has been attached. nohup.out):
...
checking --enable-pythoninterp argument... yes
checking for python2... (cached) /bin/python2
checking Python version... (cached) 2.7
checking Python is 2.3 or better... yep
checking Python's install prefix... (cached) /usr
checking Python's execution prefix... (cached) /usr
(cached) checking Python's configuration directory... (cached) /usr/local/lib/python2.7/config
(cached) checking Python's dll name... (cached) libpython2.7.so.1.0
checking if -pthread should be used... yes
checking if compile and link flags for Python are sane... yes
...
----------------------
System: Red Hat Enterprise Linux Server 7.2
Python: 2.7.12
Python was built by:
./configure --prefix=/usr/local --enable-shared LDFLAGS="-Wl,-rpath /usr/local/lib" --enable-unicode=ucs4 --with-cxx-main=g++
make && make altinstall
ln -s /usr/local/bin/python2.7 /usr/local/bin/python
Did you apply the patch for checking INCLUDEPY?
https://groups.google.com/d/msg/vim_dev/e88fjqTyfCQ/imxf0v9oAwAJ
Note that need to run "make autoconf" after patching src/configure.in.
Regards,
Ken Takata
Hi Ken,
I'm using the latest vim source code from github. the version is 7.4.2161. Do I still need apply patches?
Thanks.
BRs. Marslo
The patch is not included, because no one tested it.
(And I have totally forgotten about the patch.)
Regards,
Ken Takata
Hahaha.... Okay...
Let me have a try, anything update will let you know.
Thanks.
BRs. Marslo
Hi Ken,
Well.... the issue has been fixed somehow. I think the issue happened in Python compile, but not in vim compile.
I'm using "# make install altinstall" instead of "# make altinstall", and reboot, and the vim built works!!
configure shows:
...
checking for python2... (cached) /usr/local/bin/python2
checking Python version... (cached) 2.7
checking Python is 2.3 or better... yep
checking Python's install prefix... (cached) /usr/local
checking Python's execution prefix... (cached) /usr/local
(cached) checking Python's configuration directory... (cached) /usr/local/lib/python2.7/config
(cached) checking Python's dll name... (cached) libpython2.7.so.1.0
...
The build can be succeed, but python still cannot works in vim:
:python print 'abc'
E887: Sorry, this command is disabled, the Python's site module could not be loaded.
Press ENTER or type command to continue
Here what I did:
$ git diff *
diff --git a/src/configure.in b/src/configure.in
index 504aca6..2da7a6a 100644
--- a/src/configure.in
+++ b/src/configure.in
@@ -1186,6 +1186,7 @@ __:
@echo "python_LINKFORSHARED='$(LINKFORSHARED)'"
@echo "python_DLLLIBRARY='$(DLLLIBRARY)'"
@echo "python_INSTSONAME='$(INSTSONAME)'"
+ @echo "python_INCLUDEPY='$(INCLUDEPY)'"
@echo "python_PYTHONFRAMEWORK='$(PYTHONFRAMEWORK)'"
@echo "python_PYTHONFRAMEWORKPREFIX='$(PYTHONFRAMEWORKPREFIX)'"
@echo "python_PYTHONFRAMEWORKINSTALLDIR='$(PYTHONFRAMEWORKINSTALLDIR)'"
@@ -1240,9 +1241,9 @@ eof
PYTHON_LIBS="${vi_cv_path_python_plibs}"
if test "${vi_cv_path_python_pfx}" = "${vi_cv_path_python_epfx}"; then
- PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version} -DPYTHON_HOME='\"${vi_cv_path_python_pfx}\"'"
+ PYTHON_CFLAGS="-I${python_INCLUDEPY} -I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version} -DPYTHON_HOME='\"${vi_cv_path_python_pfx}\"'"
else
- PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version} -I${vi_cv_path_python_epfx}/include/python${vi_cv_var_python_version} -DPYTHON_HOME='\"${vi_cv_path_python_pfx}\"'"
+ PYTHON_CFLAGS="-I${python_INCLUDEPY} -I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version} -I${vi_cv_path_python_epfx}/include/python${vi_cv_var_python_version} -DPYTHON_HOME='\"${vi_cv_path_python_pfx}\"'"
fi
PYTHON_SRC="if_python.c"
PYTHON_OBJ="objects/if_python.o"
$ make autoconf
make: *** No rule to make target `autoconf'. Stop.
$ cd src/
$ make autoconf
if test ! -f configure.save; then mv configure configure.save; fi
autoconf
sed -e 's+>config.log+>auto/config.log+' -e 's+\./config.log+auto/config.log+' configure > auto/configure
chmod 755 auto/configure
mv -f configure.save configure
rm -rf autom4te.cache
rm -f auto/config.status auto/config.cache
$ cd ..
$ ./configure --prefix=$HOME/.marslo/myprograms/vim74 --enable-pythoninterp=yes --with-python-config-dir=/usr/local/lib/python2.7/config --with-features=huge --disable-smack --enable-fail-if-missing --with-compiledby=marslo@China
...
checking for python2... /usr/local/bin/python2
checking Python version... 2.7
checking Python is 2.3 or better... yep
checking Python's install prefix... /usr/local
checking Python's execution prefix... /usr/local
checking Python's configuration directory... (cached) /usr/local/lib/python2.7/config
/home/marslo/.vim/vimsrc/src/config-PyMake2206:1542: *** missing separator. Stop.
checking Python's dll name...
...