首页 > 解决方案 > 节点 gyp PYTHONPATH 问题

问题描述

我在我的项目中运行节点 8.11.3 的 MAC 并收到以下错误:

$ npm install

> chacha-native@2.0.2 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

package.json 如下:

{
  "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"
  }
}

我试图创建一个虚拟环境,但仍然有问题。我必须使用管理员帐户来安装 node-gyp,不确定这是否是这里的问题。

python -V 返回“Python 2.7.14”我什至尝试取消设置 PYTHONPATH,但我得到了同样的错误。

标签: python-2.7npmnpm-installnode-gyp

解决方案


你已经解决了这个问题吗?

我有同样的问题一个星期了。在我安装了一些 hackrf 包(使用 python3.x)后出现了这个问题。

因此,我需要 NodeJS 而不是我刚刚卸载 python3 并删除的那些 python3 包 /usr/local/lib/python3.6//usr/local/lib/python3.7/或者你拥有的任何 python3 版本。

是的,我知道这不是最好的解决方案,但至少比我猜你根本无法工作要好(这就是我的想法)

附言。也许有人根据我如何解决这个问题对此问题有一个很好的解释。

编辑:注意,pip本身不应该被删除


推荐阅读