Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python: ImportError: No module named compiler.ast #1087

Closed
ghost opened this issue Jan 11, 2018 · 4 comments
Closed

Python: ImportError: No module named compiler.ast #1087

ghost opened this issue Jan 11, 2018 · 4 comments
Labels

Comments

@ghost
Copy link

ghost commented Jan 11, 2018

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

> sharp@0.18.4 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 apollo-cache-control@0.0.7 requires a peer of graphql@^0.10.0 || ^0.11.0 but none is installed. You must install peer dependencies yourself.
npm WARN apollo-link-http@1.3.2 requires a peer of graphql@^0.11.0 but none is installed. You must install peer dependencies yourself.
npm WARN apollo-tracing@0.1.1 requires a peer of graphql@^0.10.0 || ^0.11.0 but none is installed. You must install peer dependencies yourself.
npm WARN graphql-extensions@0.0.5 requires a peer of graphql@^0.10.0 || ^0.11.0 but none is installed. You must install peer dependencies yourself.
npm WARN digital@1.0.0 No description
npm WARN digital@1.0.0 No repository field.
npm WARN digital@1.0.0 No license field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sharp@0.18.4 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the sharp@0.18.4 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
@ghost ghost changed the title Debian 9 Debian 9 - can not install Jan 11, 2018
@lovell
Copy link
Owner

lovell commented Jan 11, 2018

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.

@paultiplady
Copy link

paultiplady commented Jan 22, 2018

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.

@jnrepo
Copy link

jnrepo commented Jan 27, 2018

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

@lovell lovell changed the title Debian 9 - can not install Python: ImportError: No module named compiler.ast Jan 27, 2018
@lovell
Copy link
Owner

lovell commented Feb 3, 2018

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

@lovell lovell closed this as completed Feb 3, 2018
ZsZs73 added a commit to ZsZs73/docs that referenced this issue Apr 19, 2018
Add python-dev as build dependency otherwise node-gyp rebuild in dtrace-provider will fail with "ImportError: No module named compiler.ast".
Credit should go to lovell/sharp#1087
nafigator added a commit to nafigator/docker-library that referenced this issue Nov 9, 2019
During bootstrap compiling got this error:

Traceback (most recent call last):
  File "/var/www/html/node_modules/node-gyp/gyp/gyp_main.py", line 13, in <module>
    import gyp
  File "/var/www/html/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 8, in <module>
    import gyp.input
  File "/var/www/html/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 5, in <module>
    from compiler.ast import Const
ImportError: No module named compiler.ast

According lovell/sharp#1087 docker image needs python dev-headers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants