user4757355
user4757355

Reputation: 325

node-gyp PYTHONPATH issue

I'm in my project on a MAC running node 8.11.3 and getting the following error:

$ npm install

> [email protected] install /Users/MYUSERNAME/boatnet/observer/obs-web/node_modules/chacha-native
> node-gyp rebuild

Your PYTHONPATH points to a site-packages dir for Python 3.x but you are running Python 2.x!
     PYTHONPATH is currently: "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib:/usr/local/lib/python2.7/site-packages"
     You should `unset PYTHONPATH` to fix this.
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:336:16)
gyp ERR! stack     at emitTwo (events.js:126:13)
gyp ERR! stack     at ChildProcess.emit (events.js:214:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
gyp ERR! System Darwin 16.7.0
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 /Users/MYUSERNAME/boatnet/observer/obs-web/node_modules/chacha-native
gyp ERR! node -v v8.11.3
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok

The package.json is as follows:

{
  "name": "obs-web",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "build-webapp": "ng build --prod",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "postinstall": "node build/patch/patch-electron-fs.js"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^7.1.4",
    "@angular/cdk": "^6.4.7",
    "@angular/common": "^7.1.4",
    "@angular/compiler": "^7.1.4",
    "@angular/core": "^7.1.4",
    "@angular/forms": "^7.1.4",
    "@angular/http": "^7.1.4",
    "@angular/material": "^6.4.7",
    "@angular/platform-browser": "^7.1.4",
    "@angular/platform-browser-dynamic": "^7.1.4",
    "@angular/router": "^7.1.4",
    "chacha": "^2.1.0",
    "core-js": "^2.5.4",
    "crypto-pouch": "^3.1.3",
    "hammerjs": "^2.0.8",
    "moment": "^2.22.2",
    "node-gyp": "^3.8.0",
    "npm": "^6.4.1",
    "pouchdb": "^7.0.0",
    "pouchdb-find": "^7.0.0",
    "primeicons": "^1.0.0",
    "primeng": "^6.1.6",
    "rxjs": "^6.3.3",
    "stream": "0.0.2",
    "tslib": "^1.9.0",
    "zone.js": "~0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.11.0",
    "@angular/cli": "~7.1.4",
    "@angular/compiler-cli": "^7.1.4",
    "@angular/language-service": "^7.1.4",
    "@types/jasmine": "^2.8.11",
    "@types/jasminewd2": "^2.0.6",
    "@types/node": "^8.10.38",
    "codelyzer": "~4.2.1",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "^3.1.1",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "^2.0.4",
    "karma-jasmine": "~1.1.1",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "^5.4.1",
    "ts-node": "~5.0.1",
    "tslint": "~5.9.1",
    "typescript": "~3.1.6"
  }
}

I tried to create a virtual env but still having issues. I had to use an admin account to install node-gyp, not sure if that is the problem here.

python -V returns "Python 2.7.14" I even tried to unset PYTHONPATH and I got the same error.

Upvotes: 2

Views: 1892

Answers (1)

Steffen Meyer
Steffen Meyer

Reputation: 11

Did you already solved the issue?

I had the same problem for a week now. The issue appeared after i installed some hackrf packages (that uses python3.x).

Due to that i need NodeJS more than those python3 packages i just uninstalled python3 and deleted /usr/local/lib/python3.6/ and /usr/local/lib/python3.7/ or whatever python3 version you have.

and yea i know that is not the best solution but at least its better than if you couldnt work at all i guess (that is what i think)

ps. maybe someone has a good explanation for this issue based on how i solved it.

EDIT: Be aware, pip itself shouldn't be deleted

Upvotes: 1

Related Questions