Search code examples
pythoncentosleveldown

Compiling with python on CentOS 8 returns errors


I have installed the latest node, npm and python versions but get the following error when I try to install leveldown (using npm):

> [email protected] install /root/apps/authentication/node_modules/leveldown
> prebuild-install || node-gyp rebuild

prebuild-install WARN install No prebuilt binaries found (target=10.16.3 runtime=node arch=x64 platform=linux)
gyp ERR! configure error 
gyp ERR! stack Error: Command failed: /bin/python -c import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack   File "<string>", line 1
gyp ERR! stack     import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack                                ^
gyp ERR! stack SyntaxError: invalid syntax
gyp ERR! stack 
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:294:12)
gyp ERR! stack     at ChildProcess.emit (events.js:198:13)
gyp ERR! stack     at maybeClose (internal/child_process.js:982:16)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
gyp ERR! System Linux 4.18.0-80.11.2.el8_0.x86_64
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /root/apps/authentication/node_modules/leveldown
gyp ERR! node -v v10.16.3
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
npm WARN [email protected] No description
npm WARN [email protected] No repository field.
npm WARN [email protected] No license field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `prebuild-install || node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2020-01-08T21_40_49_710Z-debug.log

It seems that python doesn't compile on CentOS 8... any help is welcome

FYI I'm not using directly leveldown but it's a dependency of PouchDB


Solution

  • You have installed Python 3 but you are running code that expects Python 2. You can install the python2 package and then you may be able to instruct your npm install process to use /usr/bin/python2 instead of /usr/bin/python.

    If that's not possible, you should be able to symlink /usr/bin/python to /usr/bin/python2. By default, CentOS 8 doesn't have a /usr/bin/python (it has only python2 or python3 commands), so this should be harmless.


    Note that Python 2 has just reached end of life. Any software that still expects Python 2 at this point may not have seen updates in a while.