Sharp: Python: ImportError: No module named compiler.ast

Created on 11 Jan 2018  路  4Comments  路  Source: lovell/sharp

root@root:/home/kobida# npm install sharp

> [email protected] install /home/kobida/node_modules/sharp
> node-gyp rebuild

Traceback (most recent call last):
  File "/usr/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py", line 13, in <module>
    import gyp
  File "/usr/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 8, in <module>
    import gyp.input
  File "/usr/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 5, in <module>
    from compiler.ast import Const
ImportError: No module named compiler.ast
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:336:16)
gyp ERR! stack     at ChildProcess.emit (events.js:160:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:12)
gyp ERR! System Linux 4.9.0-5-amd64
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/kobida/node_modules/sharp
gyp ERR! node -v v9.4.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm WARN [email protected] requires a peer of graphql@^0.10.0 || ^0.11.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of graphql@^0.11.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of graphql@^0.10.0 || ^0.11.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of graphql@^0.10.0 || ^0.11.0 but none is installed. You must install peer dependencies yourself.
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: `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/2018-01-11T02_51_28_732Z-debug.log
question

Most helpful comment

I hit this, and fixes in the linked issue didn't work -- the install process was correctly using my python2 interpreter.

In my case the issue was that the ubuntu:16.04 docker container that I was installing in didn't contain the python dev headers, which appear to be required to get compiler / parser modules.

apt-get install python-dev fixed the problem for me.

All 4 comments

Hello, the ImportError: No module named compiler.ast error suggests something is wrong with the (conflicting?) Python installation(s) on this machine. Perhaps see #684 as it was a similar problem.

I hit this, and fixes in the linked issue didn't work -- the install process was correctly using my python2 interpreter.

In my case the issue was that the ubuntu:16.04 docker container that I was installing in didn't contain the python dev headers, which appear to be required to get compiler / parser modules.

apt-get install python-dev fixed the problem for me.

I'm also having this issue on...

  • mac osx high sierra
  • node v9

I tried different sharp versions 0.19.0 and 0.18.4

This problem relates to local Python installations. Please subscribe #186 for updates about a possible Python-less future.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

emmtte picture emmtte  路  3Comments

OleVik picture OleVik  路  3Comments

zilions picture zilions  路  3Comments

jaekunchoi picture jaekunchoi  路  3Comments

genifycom picture genifycom  路  3Comments