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

Created on 17 Jan 2017  路  4Comments  路  Source: lovell/sharp

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 [email protected] should be installed with -g

[email protected] 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!

question

All 4 comments

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

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"

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.)

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

zilions picture zilions  路  3Comments

jaydenseric picture jaydenseric  路  3Comments

natural-law picture natural-law  路  3Comments

emmtte picture emmtte  路  3Comments

kachurovskiy picture kachurovskiy  路  3Comments