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

[Question] node-gyp error: ImportError: No module named parser #684

Closed
biri opened this issue Jan 16, 2017 · 4 comments
Closed

[Question] node-gyp error: ImportError: No module named parser #684

biri opened this issue Jan 16, 2017 · 4 comments
Labels

Comments

@biri
Copy link

biri commented Jan 16, 2017

I am trying to install Sharp and I keep getting node-gyp error. I tried to find solutions online but nothing works. I started a clean instance on EC2 to check and installed the same node and npm that I have on my computer and it worked there. Can you please let me know what's the problem

I am running ubuntu 16.04

npm install sharp
npm WARN prefer global node-gyp@3.5.0 should be installed with -g

sharp@0.17.1 install /home/test/Documents/proj/node_modules/sharp
node-gyp rebuild

Traceback (most recent call last):
File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py", line 13, in
import gyp
File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/init.py", line 8, in
import gyp.input
File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 5, in
from compiler.ast import Const
File "/usr/lib/python2.7/compiler/init.py", line 29, in
from compiler.transformer import parse, parseFile
File "/usr/lib/python2.7/compiler/transformer.py", line 29, in
import parser
ImportError: No module named parser
gyp ERR! configure error
gyp ERR! stack Error: gyp failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:305:16)
gyp ERR! stack at emitTwo (events.js:100:13)
gyp ERR! stack at ChildProcess.emit (events.js:185:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:204:12)
gyp ERR! System Linux 4.4.0-57-generic
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/test/Documents/proj/node_modules/sharp
gyp ERR! node -v v5.11.1
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok

Thanks!

@lovell
Copy link
Owner

lovell commented Jan 17, 2017

Hello, ImportError: No module named parser is the salient part of the error message, and suggests modules from multiple versions of Python (2 and 3?) are conflicting with each other.

https://github.com/nodejs/node-gyp#installation
http://stackoverflow.com/questions/28247374/importerror-no-module-named-parse

@lovell lovell changed the title [Question] Keep getting node-gyp errors [Question] node-gyp error: ImportError: No module named parser Jan 17, 2017
@biri
Copy link
Author

biri commented Jan 17, 2017

Thanks @lovell. I do have python 2.7.3 installed and in usr/local/lib I also see Python 3.5. When I run python --version I get 2.7.3

I saw that node-gyp doesn't support python 3 but I am not really using python for my development at the moment so no virtual environments or anything like that.

I also noticed that on the EC2 I started from scratch and I did succeed in installing Sharp I have python 2.7.6 installed and a python 3.4 directory in /usr/local/lib.
Any suggestions on how to solve it ?

i also tried to run

"npm install --python=python2.7 sharp" and I get the same error
"npm config set python python2.7"

@lovell
Copy link
Owner

lovell commented Jan 17, 2017

If the parser module really is is missing, perhaps pip install parser might help.

(This is a problem relating to the Python setup on one specific machine so I'm probably not going to be much help.)

@biri
Copy link
Author

biri commented Jan 17, 2017

Thanks @lovell I fixed it. Apparently I had another python installed from a while ago and when I upgraded to 16.04 they collided. I removed the old one, and now I am only using the one the OS installed. Works great! Thanks

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

2 participants