Root install fail with python3


_ROOT Version:_6.16.00
Platform: CentOS Linux release 7.6.1810
Compiler: gcc (GCC) 4.8.5 20150623


I have tried to compile ROOT with python/3.6.5

cmake -Dpython=OFF -Dpython3=ON ~/data/download/root-6.16.00
cmake --build . 

The install fails with the following error:

[ 89%] Building CXX object graf2d/asimage/CMakeFiles/ASImage.dir/src/TASPluginGS.cxx.o
In file included from /path/to/home/dp004/dc-garz1/data/download/root-6.16.00/graf2d/asimage/src/TASPluginGS.cxx:40:0:
/path/to/local/Python/3.6.5/include/python3.6m/import.h:11:18: error: expected constructor, destructor, or type conversion before \u2018_PyImportZip_Init\u2019
 PyAPI_FUNC(void) _PyImportZip_Init(void);
                  ^
/path/to/local/Python/3.6.5/include/python3.6m/import.h:13:1: error: \u2018PyMODINIT_FUNC\u2019 does not name a type
 PyMODINIT_FUNC PyInit_imp(void);
 ^
/path/to/local/Python/3.6.5/include/python3.6m/import.h:15:18: error: expected constructor, destructor, or type conversion before \u2018PyImport_GetMagicNumber\u2019
 PyAPI_FUNC(long) PyImport_GetMagicNumber(void);
                  ^
/path/to/local/Python/3.6.5/include/python3.6m/import.h:16:26: error: expected constructor, destructor, or type conversion before \u2018PyImport_GetMagicTag\u2019
 PyAPI_FUNC(const char *) PyImport_GetMagicTag(void);
                          ^
/path/to/local/Python/3.6.5/include/python3.6m/import.h:17:11: error: expected constructor, destructor, or type conversion before \u2018(\u2019 token
 PyAPI_FUNC(PyObject *) PyImport_ExecCodeModule(
           ^
/path/to/local/Python/3.6.5/include/python3.6m/import.h:21:11: error: expected constructor, destructor, or type conversion before \u2018(\u2019 token
 PyAPI_FUNC(PyObject *) PyImport_ExecCodeModuleEx(
           ^
/path/to/local/Python/3.6.5/include/python3.6m/import.h:26:11: error: expected constructor, destructor, or type conversion before \u2018(\u2019 token
 PyAPI_FUNC(PyObject *) PyImport_ExecCodeModuleWithPathnames(
           ^
/path/to/local/Python/3.6.5/include/python3.6m/import.h:33:11: error: expected constructor, destructor, or type conversion before \u2018(\u2019 token
 PyAPI_FUNC(PyObject *) PyImport_ExecCodeModuleObject(
           ^
/path/to/local/Python/3.6.5/include/python3.6m/import.h:40:11: error: expected constructor, destructor, or type conversion before \u2018(\u2019 token
 PyAPI_FUNC(PyObject *) PyImport_GetModuleDict(void);
           ^
/path/to/local/Python/3.6.5/include/python3.6m/import.h:42:11: error: expected constructor, destructor, or type conversion before \u2018(\u2019 token
 PyAPI_FUNC(PyObject *) PyImport_AddModuleObject(
           ^
/path/to/local/Python/3.6.5/include/python3.6m/import.h:46:11: error: expected constructor, destructor, or type conversion before \u2018(\u2019 token
 PyAPI_FUNC(PyObject *) PyImport_AddModule(
           ^
/path/to/local/Python/3.6.5/include/python3.6m/import.h:49:11: error: expected constructor, destructor, or type conversion before \u2018(\u2019 token
 PyAPI_FUNC(PyObject *) PyImport_ImportModule(
           ^
/path/to/local/Python/3.6.5/include/python3.6m/import.h:52:11: error: expected constructor, destructor, or type conversion before \u2018(\u2019 token
 PyAPI_FUNC(PyObject *) PyImport_ImportModuleNoBlock(
           ^
/path/to/local/Python/3.6.5/include/python3.6m/import.h:55:11: error: expected constructor, destructor, or type conversion before \u2018(\u2019 token
 PyAPI_FUNC(PyObject *) PyImport_ImportModuleLevel(
           ^
/path/to/local/Python/3.6.5/include/python3.6m/import.h:63:11: error: expected constructor, destructor, or type conversion before \u2018(\u2019 token
 PyAPI_FUNC(PyObject *) PyImport_ImportModuleLevelObject(
           ^
/path/to/local/Python/3.6.5/include/python3.6m/import.h:75:11: error: expected constructor, destructor, or type conversion before \u2018(\u2019 token
 PyAPI_FUNC(PyObject *) PyImport_GetImporter(PyObject *path);
           ^
/path/to/local/Python/3.6.5/include/python3.6m/import.h:76:11: error: expected constructor, destructor, or type conversion before \u2018(\u2019 token
 PyAPI_FUNC(PyObject *) PyImport_Import(PyObject *name);
           ^
/path/to/local/Python/3.6.5/include/python3.6m/import.h:77:11: error: expected constructor, destructor, or type conversion before \u2018(\u2019 token
 PyAPI_FUNC(PyObject *) PyImport_ReloadModule(PyObject *m);
           ^
/path/to/local/Python/3.6.5/include/python3.6m/import.h:78:18: error: expected constructor, destructor, or type conversion before \u2018PyImport_Cleanup\u2019
 PyAPI_FUNC(void) PyImport_Cleanup(void);
                  ^
/path/to/local/Python/3.6.5/include/python3.6m/import.h:80:17: error: expected constructor, destructor, or type conversion before \u2018PyImport_ImportFrozenModuleObject\u2019
 PyAPI_FUNC(int) PyImport_ImportFrozenModuleObject(
                 ^
/path/to/local/Python/3.6.5/include/python3.6m/import.h:84:17: error: expected constructor, destructor, or type conversion before \u2018PyImport_ImportFrozenModule\u2019
 PyAPI_FUNC(int) PyImport_ImportFrozenModule(
                 ^
/path/to/local/Python/3.6.5/include/python3.6m/import.h:97:18: error: expected constructor, destructor, or type conversion before \u2018_PyImport_ReInitLock\u2019
 PyAPI_FUNC(void) _PyImport_ReInitLock(void);
                  ^
/path/to/local/Python/3.6.5/include/python3.6m/import.h:99:11: error: expected constructor, destructor, or type conversion before \u2018(\u2019 token
 PyAPI_FUNC(PyObject *) _PyImport_FindBuiltin(
           ^
/path/to/local/Python/3.6.5/include/python3.6m/import.h:102:11: error: expected constructor, destructor, or type conversion before \u2018(\u2019 token
 PyAPI_FUNC(PyObject *) _PyImport_FindExtensionObject(PyObject *, PyObject *);
           ^
/path/to/local/Python/3.6.5/include/python3.6m/import.h:103:17: error: expected constructor, destructor, or type conversion before \u2018_PyImport_FixupBuiltin\u2019
 PyAPI_FUNC(int) _PyImport_FixupBuiltin(
                 ^
/path/to/local/Python/3.6.5/include/python3.6m/import.h:107:17: error: expected constructor, destructor, or type conversion before \u2018_PyImport_FixupExtensionObject\u2019
 PyAPI_FUNC(int) _PyImport_FixupExtensionObject(PyObject*, PyObject *, PyObject *);
                 ^
/path/to/local/Python/3.6.5/include/python3.6m/import.h:111:5: error: \u2018PyObject\u2019 does not name a type
     PyObject* (*initfunc)(void);
     ^
/path/to/local/Python/3.6.5/include/python3.6m/import.h:113:31: error: expected constructor, destructor, or type conversion before \u2018PyImport_Inittab\u2019
 PyAPI_DATA(struct _inittab *) PyImport_Inittab;
                               ^
/path/to/local/Python/3.6.5/include/python3.6m/import.h:114:17: error: expected constructor, destructor, or type conversion before \u2018PyImport_ExtendInittab\u2019
 PyAPI_FUNC(int) PyImport_ExtendInittab(struct _inittab *newtab);
                 ^
/path/to/local/Python/3.6.5/include/python3.6m/import.h:117:11: error: expected constructor, destructor, or type conversion before \u2018(\u2019 token
 PyAPI_DATA(PyTypeObject) PyNullImporter_Type;
           ^
/path/to/local/Python/3.6.5/include/python3.6m/import.h:119:17: error: expected constructor, destructor, or type conversion before \u2018PyImport_AppendInittab\u2019
 PyAPI_FUNC(int) PyImport_AppendInittab(
                 ^
/path/to/local/Python/3.6.5/include/python3.6m/import.h:134:36: error: expected constructor, destructor, or type conversion before \u2018PyImport_FrozenModules\u2019
 PyAPI_DATA(const struct _frozen *) PyImport_FrozenModules;
                                    ^
/path/to/home/dp004/dc-garz1/data/download/root-6.16.00/graf2d/asimage/src/TASPluginGS.cxx: In member function \u2018virtual ASImage* TASPluginGS::File2ASImage(const char*)\u2019:
/path/to/home/dp004/dc-garz1/data/download/root-6.16.00/graf2d/asimage/src/TASPluginGS.cxx:144:4: error: \u2018ASImageImportParams\u2019 was not declared in this scope
    ASImageImportParams params;
    ^
/path/to/home/dp004/dc-garz1/data/download/root-6.16.00/graf2d/asimage/src/TASPluginGS.cxx:144:24: error: expected \u2018;\u2019 before \u2018params\u2019
    ASImageImportParams params;
                        ^
/path/to/home/dp004/dc-garz1/data/download/root-6.16.00/graf2d/asimage/src/TASPluginGS.cxx:145:4: error: \u2018params\u2019 was not declared in this scope
    params.flags =  0;
    ^
/path/to/home/dp004/dc-garz1/data/download/root-6.16.00/graf2d/asimage/src/TASPluginGS.cxx:148:20: error: \u2018SCL_DO_ALL\u2019 was not declared in this scope
    params.filter = SCL_DO_ALL;
                    ^
/path/to/home/dp004/dc-garz1/data/download/root-6.16.00/graf2d/asimage/src/TASPluginGS.cxx:152:20: error: \u2018ASA_ASImage\u2019 was not declared in this scope
    params.format = ASA_ASImage;
                    ^
/path/to/home/dp004/dc-garz1/data/download/root-6.16.00/graf2d/asimage/src/TASPluginGS.cxx:156:63: error: \u2018PNGBuff2ASimage\u2019 was not declared in this scope
    ASImage *ret = PNGBuff2ASimage((CARD8 *)raw.Data(), &params);
                                                               ^
gmake[2]: *** [graf2d/asimage/CMakeFiles/ASImage.dir/src/TASPluginGS.cxx.o] Error 1
gmake[1]: *** [graf2d/asimage/CMakeFiles/ASImage.dir/all] Error 2
gmake: *** [all] Error 2

Dear @afylot

In your build directory there should be a CMakeCache.txt file. Can you check that the following properties in that file all point to the same Python installation?

  • PYTHON_EXECUTABLE
  • PYTHON_INCLUDE_DIR
  • PYTHON_LIBRARY

I can already see that the installation is pointing to the wrong python executable

$/usr/bin/python --version
Python 2.7.5

not python 3

$ fgrep PYTHON_EXECUTABLE CMakeCache.txt 
PYTHON_EXECUTABLE:FILEPATH=/usr/bin/python
//ADVANCED property for variable: PYTHON_EXECUTABLE
PYTHON_EXECUTABLE-ADVANCED:INTERNAL=1

$ fgrep PYTHON_INCLUDE_DIR CMakeCache.txt 

$ fgrep PYTHON_LIBRARY CMakeCache.txt 
PYTHON_LIBRARY:FILEPATH=PYTHON_LIBRARY-NOTFOUND
PYTHON_LIBRARY_DEBUG:FILEPATH=PYTHON_LIBRARY_DEBUG-NOTFOUND
PYTHON_LIBRARY_RELEASE:FILEPATH=PYTHON_LIBRARY_RELEASE-NOTFOUND
//ADVANCED property for variable: PYTHON_LIBRARY
PYTHON_LIBRARY-ADVANCED:INTERNAL=1
//ADVANCED property for variable: PYTHON_LIBRARY_DEBUG
PYTHON_LIBRARY_DEBUG-ADVANCED:INTERNAL=1
//ADVANCED property for variable: PYTHON_LIBRARY_RELEASE
PYTHON_LIBRARY_RELEASE-ADVANCED:INTERNAL=1

That looks like the reason of your issue, then.

Can you redo the cmake command, this time specifying all the options I listed in my previous message? For example cmake -DPYTHON_EXECUTABLE=path_to_your_python_executable ...

with cmake -DPYTHON_EXECUTABLE=/path/to/python3

$ fgrep PYTHON_EXECUTABLE CMakeCache.txt
CMAKE_INVOKE:STRING=/path/to/local/cmake/3.11.4/bin/cmake -DPYTHON_EXECUTABLE="/path/to/local/Python/3.6.5/bin/python3" /path/to/data/download/root-6.16.00
PYTHON_EXECUTABLE:FILEPATH=/path/to/local/Python/3.6.5/bin/python3
PYTHON_EXECUTABLE-CACHED:STRING=/path/to/local/Python/3.6.5/bin/python3
//ADVANCED property for variable: PYTHON_EXECUTABLE
PYTHON_EXECUTABLE-ADVANCED:INTERNAL=1

$ fgrep PYTHON_INCLUDE_DIR CMakeCache.txt
PYTHON_INCLUDE_DIR:PATH=/path/to/local/Python/3.6.5/include/python3.6m
//ADVANCED property for variable: PYTHON_INCLUDE_DIR
PYTHON_INCLUDE_DIR-ADVANCED:INTERNAL=1

$ fgrep PYTHON_LIBRARY CMakeCache.txt
PYTHON_LIBRARY:FILEPATH=/path/to/local/Python/3.6.5/lib/libpython3.6m.so
PYTHON_LIBRARY_DEBUG:FILEPATH=PYTHON_LIBRARY_DEBUG-NOTFOUND
//ADVANCED property for variable: PYTHON_LIBRARY
PYTHON_LIBRARY-ADVANCED:INTERNAL=1
//ADVANCED property for variable: PYTHON_LIBRARY_DEBUG
PYTHON_LIBRARY_DEBUG-ADVANCED:INTERNAL=1
Now I get the following error:

[ 87%] Building CXX object graf2d/asimage/CMakeFiles/ASImage.dir/src/TASPluginGS.cxx.o
In file included from /path/to/data/download/root-6.16.00/graf2d/asimage/src/TASPluginGS.cxx:40:0:
/path/to/local/Python/3.6.5/include/python3.6m/import.h:11:18: error: expected constructor, destructor, or type conversion before \u2018_PyImportZip_Init\u2019
PyAPI_FUNC(void) _PyImportZip_Init(void);
^
/path/to/local/Python/3.6.5/include/python3.6m/import.h:13:1: error: \u2018PyMODINIT_FUNC\u2019 does not name a type
PyMODINIT_FUNC PyInit_imp(void);
^
/path/to/local/Python/3.6.5/include/python3.6m/import.h:15:18: error: expected constructor, destructor, or type conversion before \u2018PyImport_GetMagicNumber\u2019
PyAPI_FUNC(long) PyImport_GetMagicNumber(void);
^
/path/to/local/Python/3.6.5/include/python3.6m/import.h:16:26: error: expected constructor, destructor, or type conversion before \u2018PyImport_GetMagicTag\u2019
PyAPI_FUNC(const char *) PyImport_GetMagicTag(void);
^
/path/to/local/Python/3.6.5/include/python3.6m/import.h:17:11: error: expected constructor, destructor, or type conversion before \u2018(\u2019 token
PyAPI_FUNC(PyObject *) PyImport_ExecCodeModule(
^
/path/to/local/Python/3.6.5/include/python3.6m/import.h:21:11: error: expected constructor, destructor, or type conversion before \u2018(\u2019 token
PyAPI_FUNC(PyObject *) PyImport_ExecCodeModuleEx(
^
/path/to/local/Python/3.6.5/include/python3.6m/import.h:26:11: error: expected constructor, destructor, or type conversion before \u2018(\u2019 token
PyAPI_FUNC(PyObject *) PyImport_ExecCodeModuleWithPathnames(
^
/path/to/local/Python/3.6.5/include/python3.6m/import.h:33:11: error: expected constructor, destructor, or type conversion before \u2018(\u2019 token
PyAPI_FUNC(PyObject *) PyImport_ExecCodeModuleObject(
^
/path/to/local/Python/3.6.5/include/python3.6m/import.h:40:11: error: expected constructor, destructor, or type conversion before \u2018(\u2019 token
PyAPI_FUNC(PyObject *) PyImport_GetModuleDict(void);
^
/path/to/local/Python/3.6.5/include/python3.6m/import.h:42:11: error: expected constructor, destructor, or type conversion before \u2018(\u2019 token
PyAPI_FUNC(PyObject *) PyImport_AddModuleObject(
^
/path/to/local/Python/3.6.5/include/python3.6m/import.h:46:11: error: expected constructor, destructor, or type conversion before \u2018(\u2019 token
PyAPI_FUNC(PyObject *) PyImport_AddModule(
^
/path/to/local/Python/3.6.5/include/python3.6m/import.h:49:11: error: expected constructor, destructor, or type conversion before \u2018(\u2019 token
PyAPI_FUNC(PyObject *) PyImport_ImportModule(
^
/path/to/local/Python/3.6.5/include/python3.6m/import.h:52:11: error: expected constructor, destructor, or type conversion before \u2018(\u2019 token
PyAPI_FUNC(PyObject *) PyImport_ImportModuleNoBlock(
^
/path/to/local/Python/3.6.5/include/python3.6m/import.h:55:11: error: expected constructor, destructor, or type conversion before \u2018(\u2019 token
PyAPI_FUNC(PyObject *) PyImport_ImportModuleLevel(
^
/path/to/local/Python/3.6.5/include/python3.6m/import.h:63:11: error: expected constructor, destructor, or type conversion before \u2018(\u2019 token
PyAPI_FUNC(PyObject *) PyImport_ImportModuleLevelObject(
^
/path/to/local/Python/3.6.5/include/python3.6m/import.h:75:11: error: expected constructor, destructor, or type conversion before \u2018(\u2019 token
PyAPI_FUNC(PyObject *) PyImport_GetImporter(PyObject *path);
^
/path/to/local/Python/3.6.5/include/python3.6m/import.h:76:11: error: expected constructor, destructor, or type conversion before \u2018(\u2019 token
PyAPI_FUNC(PyObject *) PyImport_Import(PyObject *name);
^
/path/to/local/Python/3.6.5/include/python3.6m/import.h:77:11: error: expected constructor, destructor, or type conversion before \u2018(\u2019 token
PyAPI_FUNC(PyObject *) PyImport_ReloadModule(PyObject *m);
^
/path/to/local/Python/3.6.5/include/python3.6m/import.h:78:18: error: expected constructor, destructor, or type conversion before \u2018PyImport_Cleanup\u2019
PyAPI_FUNC(void) PyImport_Cleanup(void);
^
/path/to/local/Python/3.6.5/include/python3.6m/import.h:80:17: error: expected constructor, destructor, or type conversion before \u2018PyImport_ImportFrozenModuleObject\u2019
PyAPI_FUNC(int) PyImport_ImportFrozenModuleObject(
^
/path/to/local/Python/3.6.5/include/python3.6m/import.h:84:17: error: expected constructor, destructor, or type conversion before \u2018PyImport_ImportFrozenModule\u2019
PyAPI_FUNC(int) PyImport_ImportFrozenModule(
^
/path/to/local/Python/3.6.5/include/python3.6m/import.h:97:18: error: expected constructor, destructor, or type conversion before \u2018_PyImport_ReInitLock\u2019
PyAPI_FUNC(void) _PyImport_ReInitLock(void);
^
/path/to/local/Python/3.6.5/include/python3.6m/import.h:99:11: error: expected constructor, destructor, or type conversion before \u2018(\u2019 token
PyAPI_FUNC(PyObject *) _PyImport_FindBuiltin(
^
/path/to/local/Python/3.6.5/include/python3.6m/import.h:102:11: error: expected constructor, destructor, or type conversion before \u2018(\u2019 token
PyAPI_FUNC(PyObject *) _PyImport_FindExtensionObject(PyObject *, PyObject );
^
/path/to/local/Python/3.6.5/include/python3.6m/import.h:103:17: error: expected constructor, destructor, or type conversion before \u2018_PyImport_FixupBuiltin\u2019
PyAPI_FUNC(int) _PyImport_FixupBuiltin(
^
/path/to/local/Python/3.6.5/include/python3.6m/import.h:107:17: error: expected constructor, destructor, or type conversion before \u2018_PyImport_FixupExtensionObject\u2019
PyAPI_FUNC(int) _PyImport_FixupExtensionObject(PyObject
, PyObject *, PyObject );
^
/path/to/local/Python/3.6.5/include/python3.6m/import.h:111:5: error: \u2018PyObject\u2019 does not name a type
PyObject
(*initfunc)(void);
^
/path/to/local/Python/3.6.5/include/python3.6m/import.h:113:31: error: expected constructor, destructor, or type conversion before \u2018PyImport_Inittab\u2019
PyAPI_DATA(struct _inittab *) PyImport_Inittab;
^
/path/to/local/Python/3.6.5/include/python3.6m/import.h:114:17: error: expected constructor, destructor, or type conversion before \u2018PyImport_ExtendInittab\u2019
PyAPI_FUNC(int) PyImport_ExtendInittab(struct _inittab newtab);
^
/path/to/local/Python/3.6.5/include/python3.6m/import.h:117:11: error: expected constructor, destructor, or type conversion before \u2018(\u2019 token
PyAPI_DATA(PyTypeObject) PyNullImporter_Type;
^
/path/to/local/Python/3.6.5/include/python3.6m/import.h:119:17: error: expected constructor, destructor, or type conversion before \u2018PyImport_AppendInittab\u2019
PyAPI_FUNC(int) PyImport_AppendInittab(
^
/path/to/local/Python/3.6.5/include/python3.6m/import.h:134:36: error: expected constructor, destructor, or type conversion before \u2018PyImport_FrozenModules\u2019
PyAPI_DATA(const struct _frozen ) PyImport_FrozenModules;
^
/path/to/data/download/root-6.16.00/graf2d/asimage/src/TASPluginGS.cxx: In member function \u2018virtual ASImage
TASPluginGS::File2ASImage(const char
)\u2019:
/path/to/data/download/root-6.16.00/graf2d/asimage/src/TASPluginGS.cxx:144:4: error: \u2018ASImageImportParams\u2019 was not declared in this scope
ASImageImportParams params;
^
/path/to/data/download/root-6.16.00/graf2d/asimage/src/TASPluginGS.cxx:144:24: error: expected \u2018;\u2019 before \u2018params\u2019
ASImageImportParams params;
^
/path/to/data/download/root-6.16.00/graf2d/asimage/src/TASPluginGS.cxx:145:4: error: \u2018params\u2019 was not declared in this scope
params.flags = 0;
^
/path/to/data/download/root-6.16.00/graf2d/asimage/src/TASPluginGS.cxx:148:20: error: \u2018SCL_DO_ALL\u2019 was not declared in this scope
params.filter = SCL_DO_ALL;
^
/path/to/data/download/root-6.16.00/graf2d/asimage/src/TASPluginGS.cxx:152:20: error: \u2018ASA_ASImage\u2019 was not declared in this scope
params.format = ASA_ASImage;
^
/path/to/data/download/root-6.16.00/graf2d/asimage/src/TASPluginGS.cxx:156:63: error: \u2018PNGBuff2ASimage\u2019 was not declared in this scope
ASImage *ret = PNGBuff2ASimage((CARD8 *)raw.Data(), &params);
^
gmake[2]: *** [graf2d/asimage/CMakeFiles/ASImage.dir/src/TASPluginGS.cxx.o] Error 1
gmake[1]: *** [graf2d/asimage/CMakeFiles/ASImage.dir/all] Error 2
gmake: *** [all] Error 2

What compiler are you using? Most of the errors come from a Python header (import.h).

@amadio have you seen this before?

I’ve never seen these errors. Please don’t add -Dpython=OFF, this will disable Python altogether. Do cmake . -Dpython=ON and try to continue the build. If you need to choose a different Python than the default, you should pass only the -DPYTHON_EXECUTABLE=... option to CMake.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.