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

ImportError: No module named compiler.ast on embedded linux #1524

Closed
danielloczi opened this issue Aug 10, 2018 · 6 comments
Closed

ImportError: No module named compiler.ast on embedded linux #1524

danielloczi opened this issue Aug 10, 2018 · 6 comments

Comments

@danielloczi
Copy link

Hi! I tried to install mutliple npm packages (i2c-bus, i2c, ioctl) on linux, but all of them failed. I narrowed down the issue to node-gyp rebuild command. If I downloaded the source of i2c-bus and tried to run node-gyp rebuild it also failed.

  • Node Version: v8.4.0
  • Platform: Linux sama5d27-som1-ek-sd 4.9.87-linux4sam_5.8 Make 0.6.x work #1 Thu Aug 2 08:44:57 UTC 2018 armv7l armv7l armv7l GNU/Linux
  • Compiler: gcc version 7.3.0 (GCC)
  • Module: npm install i2c-bus, npm install i2c, npm install ioctl

output of
npm install node-gyp --python=python2.7
command:

Verbose output (from npm install node-gyp --python=python2.7):
gyp info it worked if it ends with ok
gyp verb cli [ '/usr/bin/node',
gyp verb cli   '/usr/bin/node-gyp',
gyp verb cli   'rebuild',
gyp verb cli   '--verbose',
gyp verb cli   '--python',
gyp verb cli   '/usr/bin/python2.7' ]
gyp info using [email protected]
gyp info using [email protected] | linux | arm
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp verb command configure []
gyp verb check python checking for Python executable "/usr/bin/python2.7" in the PATH
gyp verb `which` succeeded /usr/bin/python2.7 /usr/bin/python2.7
gyp verb check python version `/usr/bin/python2.7 -c "import sys; print "2.7.13
gyp verb check python version .%s.%s" % sys.version_info[:3];"` returned: %j
gyp verb get node dir no --target version specified, falling back to host node version: 8.4.0
gyp verb command install [ '8.4.0' ]
gyp verb install input version string "8.4.0"
gyp verb install installing version: 8.4.0
gyp verb install --ensure was passed, so won't reinstall if already installed
gyp verb install version is already installed, need to check "installVersion"
gyp verb got "installVersion" 9
gyp verb needs "installVersion" 9
gyp verb install version is good
gyp verb get node dir target node version installed: 8.4.0
gyp verb build dir attempting to create "build" dir: /home/root/i2c-bus-git/i2c-bus/build
gyp verb build dir "build" dir needed to be created? /home/root/i2c-bus-git/i2c-bus/build
gyp verb build/config.gypi creating config file
gyp verb build/config.gypi writing out config file: /home/root/i2c-bus-git/i2c-bus/build/config.gypi
gyp verb config.gypi checking for gypi file: /home/root/i2c-bus-git/i2c-bus/config.gypi
gyp verb common.gypi checking for gypi file: /home/root/i2c-bus-git/i2c-bus/common.gypi
gyp verb gyp gyp format was not specified; forcing "make"
gyp info spawn /usr/bin/python2.7
gyp info spawn args [ '/usr/lib/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/home/root/i2c-bus-git/i2c-bus/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/usr/lib/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/home/root/.node-gyp/8.4.0/include/node/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/home/root/.node-gyp/8.4.0',
gyp info spawn args   '-Dnode_gyp_dir=/usr/lib/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/home/root/.node-gyp/8.4.0/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/home/root/i2c-bus-git/i2c-bus',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.' ]
Traceback (most recent call last):
  File "/usr/lib/node_modules/node-gyp/gyp/gyp_main.py", line 13, in <module>
    import gyp
  File "/usr/lib/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 8, in <module>
    import gyp.input
  File "/usr/lib/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/node-gyp/lib/configure.js:345:16)
gyp ERR! stack     at emitTwo (events.js:125:13)
gyp ERR! stack     at ChildProcess.emit (events.js:213:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Linux 4.9.87-linux4sam_5.8
gyp ERR! command "/usr/bin/node" "/usr/bin/node-gyp" "rebuild" "--verbose" "--python" "/usr/bin/python2.7"
gyp ERR! cwd /home/root/i2c-bus-git/i2c-bus
gyp ERR! node -v v8.4.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
@hacker
Copy link

hacker commented Jan 5, 2019

This is an old issue, but I recently experienced the same. Turned out that the distribution (debian on pine64, don't remember which flavor if there are many) had python-minimal package installed, installing python2.7 fixed the problem.

@pauldraper
Copy link

pauldraper commented Mar 19, 2019

Ah, I love the smell of Python installs to run JavaScript.

@rvagg
Copy link
Member

rvagg commented Jun 20, 2019

seems like it's a python installation problem
we should have python3 support soon too which may help resolve things like this

@cclauss
Copy link
Contributor

cclauss commented Jul 9, 2019

@ExCyb
Copy link

ExCyb commented May 12, 2020

As far as I understand, when I install node in Ubuntu (using curl... etc., as recommended by Node), it installs python2.7-minimal, and the package does not include ast module. I have installed python-2.7 package to solve that.

@cclauss
Copy link
Contributor

cclauss commented May 12, 2020

Just install Python 3 instead. Python 2 died on 1/1/2020.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants