项目场景: gyp verb check python checking for Python executable python2 in the PATH

Posted 大碗拉面

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了项目场景: gyp verb check python checking for Python executable python2 in the PATH相关的知识,希望对你有一定的参考价值。

项目场景: gyp verb check python checking for Python executable “python2” in the PATH

环境

​ node v16.15.0

​ npm 8.5.5

npm install 报错


问题描述

gyp verb check python checking for Python executable "python2" in the PATH
npm ERR! gyp verb `which` failed Error: not found: python2
npm ERR! gyp verb `which` failed     at getNotFoundError (D:\\demandindex\\node_modules\\which\\which.js:13:12)
npm ERR! gyp verb `which` failed     at F (D:\\demandindex\\node_modules\\which\\which.js:68:19)
npm ERR! gyp verb `which` failed     at E (D:\\demandindex\\node_modules\\which\\which.js:80:29)
npm ERR! gyp verb `which` failed     at D:\\demandindex\\node_modules\\which\\which.js:89:16
npm ERR! gyp verb `which` failed     at D:\\demandindex\\node_modules\\isexe\\index.js:42:5
npm ERR! gyp verb `which` failed     at D:\\demandindex\\node_modules\\isexe\\windows.js:36:5
npm ERR! gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:198:21)
npm ERR! gyp verb `which` failed  python2 Error: not found: python2
npm ERR! gyp verb `which` failed     at getNotFoundError (D:\\demandindex\\node_modules\\which\\which.js:13:12)
npm ERR! gyp verb `which` failed     at F (D:\\demandindex\\node_modules\\which\\which.js:68:19)
npm ERR! gyp verb `which` failed     at E (D:\\demandindex\\node_modules\\which\\which.js:80:29)
npm ERR! gyp verb `which` failed     at D:\\demandindex\\node_modules\\which\\which.js:89:16
npm ERR! gyp verb `which` failed     at D:\\demandindex\\node_modules\\isexe\\index.js:42:5
npm ERR! gyp verb `which` failed     at D:\\demandindex\\node_modules\\isexe\\windows.js:36:5
npm ERR! gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:198:21) 
npm ERR! gyp verb `which` failed   code: 'ENOENT'
npm ERR! gyp verb `which` failed 
npm ERR! gyp verb check python checking for Python executable "python" in the PATH
npm ERR! gyp verb `which` succeeded python C:\\Program Files\\python\\python.EXE
npm ERR! gyp verb check python version `C:\\Program Files\\python\\python.EXE -c "import platform; print(platform.python_version());"` returned: "3.8.6\\r\\n"

最开始以为是缺少python2.7

安装了 python2.7 和 windows-build-tools以后依然报错


原因分析:

node-sass和 node版本不对应

我之前的node-sass版本是4.7.2

NodeJSSupported node-sass versionNode Module
Node 177.0+102
Node 166.0+93
Node 155.0+, <7.088
Node 144.14+83
Node 134.13+, <5.079
Node 124.12+, <8.072
Node 114.10+, <5.067
Node 104.9+, <6.064
Node 84.5.3+, <5.057
Node <8<5.0<57

解决方案:

node-sass 版本修改6.0.1

在执行 npm install

解决

无法在 heroku 上构建和部署 Rails 6.0.4.1 应用程序 - 引发 gyp verb cli 错误

【中文标题】无法在 heroku 上构建和部署 Rails 6.0.4.1 应用程序 - 引发 gyp verb cli 错误【英文标题】:Unable to build and deploy Rails 6.0.4.1 app on heroku - Throws gyp verb cli error 【发布时间】:2022-01-20 20:16:28 【问题描述】:

嗨,我在 heroku 上部署了一个分支并抛出了这个错误。我也尝试部署一个运行良好的分支,但这也显示了同样的错误。

本地纱线版本:1.22.17 本地节点版本:v12.22.7 请帮忙!!!

尝试在没有 yarn.lock 和 package-lock 的情况下进行构建。

这是通过 CLI 启动 Heroku 部署构建日志的方式

yarn install v1.22.17
remote:        warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
remote:        [1/5] Validating package.json...
remote:        [2/5] Resolving packages...
remote:        [3/5] Fetching packages...
remote:        [4/5] Linking dependencies...
remote:        warning " > webpack-dev-server@4.6.0" has unmet peer dependency "webpack@^4.37.0 || ^5.0.0".
remote:        warning "webpack-dev-server > webpack-dev-middleware@5.2.1" has unmet peer dependency "webpack@^4.0.0 || ^5.0.0".
remote:        [5/5] Building fresh packages...
remote:        error /tmp/build_df192222/node_modules/@rails/webpacker/node_modules/node-sass: Command failed.
remote:        Exit code: 1
remote:        Command: node scripts/build.js
remote:        Arguments: 
remote:        Directory: /tmp/build_df192222/node_modules/@rails/webpacker/node_modules/node-sass
remote:        Output:
remote:        Building: /tmp/build_df192222/bin/node /tmp/build_df192222/node_modules/@rails/webpacker/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
remote:        gyp info it worked if it ends with ok
remote:        gyp verb cli [
remote:        gyp verb cli   '/tmp/build_df192222/bin/node',
remote:        gyp verb cli   '/tmp/build_df192222/node_modules/@rails/webpacker/node_modules/node-gyp/bin/node-gyp.js',
remote:        gyp verb cli   'rebuild',

。 . . . . `

remote:        /app/.node-gyp/16.13.1/include/node/v8-internal.h: In function ‘void v8::internal::PerformCastCheck(T*)’:
remote:        /app/.node-gyp/16.13.1/include/node/v8-internal.h:492:38: error: ‘remove_cv_t’ is not a member of ‘std’; did you mean ‘remove_cv’?
remote:          492 |             !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data);
remote:              |                                      ^~~~~~~~~~~
remote:              |                                      remove_cv
remote:        /app/.node-gyp/16.13.1/include/node/v8-internal.h:492:38: error: ‘remove_cv_t’ is not a member of ‘std’; did you mean ‘remove_cv’?
remote:          492 |             !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data);
remote:              |                                      ^~~~~~~~~~~
remote:              |                                      remove_cv
remote:        /app/.node-gyp/16.13.1/include/node/v8-internal.h:492:50: error: template argument 2 is invalid
remote:          492 |             !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data);
remote:              |                                                  ^
remote:        /app/.node-gyp/16.13.1/include/node/v8-internal.h:492:63: error: ‘::Perform’ has not been declared
remote:          492 |             !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data);
remote:              |                                                               ^~~~~~~
remote:        ../src/binding.cpp: In function ‘Nan::NAN_METHOD_RETURN_TYPE render(Nan::NAN_METHOD_ARGS_TYPE)’:
remote:        ../src/binding.cpp:284:98: warning: cast between incompatible function types from ‘void (*)(uv_work_t*)’ aka ‘void (*)(uv_work_s*)’ to ‘uv_after_work_cb’ aka ‘void (*)(uv_work_s*, int)’ [-Wcast-function-type]
remote:          284 |     int status = uv_queue_work(uv_default_loop(), &ctx_w->request, compile_it, (uv_after_work_cb)MakeCallback);
remote:              |                                                                                                  ^~~~~~~~~~~~
remote:        ../src/binding.cpp: In function ‘Nan::NAN_METHOD_RETURN_TYPE render_file(Nan::NAN_METHOD_ARGS_TYPE)’:
remote:        ../src/binding.cpp:320:98: warning: cast between incompatible function types from ‘void (*)(uv_work_t*)’ aka ‘void (*)(uv_work_s*)’ to ‘uv_after_work_cb’ aka ‘void (*)(uv_work_s*, int)’ [-Wcast-function-type]
remote:          320 |     int status = uv_queue_work(uv_default_loop(), &ctx_w->request, compile_it, (uv_after_work_cb)MakeCallback);
remote:              |                                                                                                  ^~~~~~~~~~~~
remote:        In file included from ../../../../../nan/nan.h:58,
remote:                         from ../src/binding.cpp:1:
remote:        ../src/binding.cpp: At global scope:
remote:        /app/.node-gyp/16.13.1/include/node/node.h:821:43: warning: cast between incompatible function types from ‘void (*)(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE)’ aka ‘void (*)(v8::Local<v8::Object>)’ to ‘node::addon_register_func’ aka ‘void (*)(v8::Local<v8::Object>, v8::Local<v8::Value>, void*)’ [-Wcast-function-type]
remote:          821 |       (node::addon_register_func) (regfunc),                          \
remote:              |                                           ^
remote:        /app/.node-gyp/16.13.1/include/node/node.h:855:3: note: in expansion of macro ‘NODE_MODULE_X’
remote:          855 |   NODE_MODULE_X(modname, regfunc, NULL, 0)  // NOLINT (readability/null_usage)
remote:              |   ^~~~~~~~~~~~~
remote:        ../src/binding.cpp:358:1: note: in expansion of macro ‘NODE_MODULE’
remote:          358 | NODE_MODULE(binding, RegisterModule);
remote:              | ^~~~~~~~~~~
remote:        make: *** [binding.target.mk:133: Release/obj.target/binding/src/binding.o] Error 1
remote:        make: Leaving directory '/tmp/build_df192222/node_modules/@rails/webpacker/node_modules/node-sass/build'
remote:        gyp ERR! build error 
remote:        gyp ERR! stack Error: `make` failed with exit code: 2
remote:        gyp ERR! stack     at ChildProcess.onExit (/tmp/build_df192222/node_modules/@rails/webpacker/node_modules/node-gyp/lib/build.js:262:23)
remote:        gyp ERR! stack     at ChildProcess.emit (node:events:390:28)
remote:        gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
remote:        gyp ERR! System Linux 4.4.0-1097-aws
remote:        gyp ERR! command "/tmp/build_df192222/bin/node" "/tmp/build_df192222/node_modules/@rails/webpacker/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
remote:        gyp ERR! cwd /tmp/build_df192222/node_modules/@rails/webpacker/node_modules/node-sass
remote:        gyp ERR! node -v v16.13.1
remote:        gyp ERR! node-gyp -v v3.8.0
remote:        gyp ERR! not ok 
remote:        Build failed with error code: 1
remote: 
remote:  !
remote:  !     Precompiling assets failed.
remote:  !
remote:  !     Push rejected, failed to compile Ruby app.
remote: 
remote:  !     Push failed

虽然它是一个 Rails 应用程序,但我在 package.json 中添加了引擎中的节点。


  "name": "travel_empire",
  "private": true,
  "dependencies": 
    "@fortawesome/fontawesome-free": "^5.15.4",
    "@popperjs/core": "^2.10.2",
    "@rails/actioncable": "^6.0.0",
    "@rails/activestorage": "^6.0.0",
    "@rails/ujs": "^6.0.0",
    "@rails/webpacker": "4.3.0",
    "bootstrap": "4.3.1",
    "bootstrap-icons": "^1.5.0",
    "easy-autocomplete": "^1.3.5",
    "jquery": "^3.6.0",
    "jquery-ui-dist": "^1.12.1",
    "js-autocomplete": "^1.0.4",
    "node-sass": "^7.0.0",
    "popper.js": "^1.16.1",
    "turbolinks": "^5.2.0"
  ,
  "version": "0.1.0",
  "devDependencies": 
    "webpack-dev-server": "^4.6.0"
  ,
  "engines": 
    "node": "16.x"
  

宝石文件

source 'https://rubygems.org'
git_source(:github)  |repo| "https://github.com/#repo.git" 

ruby '2.7.3'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 6.0.3', '>= 6.0.3.7'

gem 'mongoid', git: 'https://github.com/mongodb/mongoid.git'


# Use Puma as the app server
gem 'puma', '~> 4.1'
# Use SCSS for stylesheets
gem 'sass-rails', '>= 6'
# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker
gem 'webpacker', '~> 4.0'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.7'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use Active Model has_secure_password


# Use Active Storage variant
# gem 'image_processing', '~> 1.2'


gem 'axlsx'
gem 'caxlsx_rails'


#Bootstrap for UI
gem 'bootstrap', '~> 5.1.0'
gem 'bootstrap-timepicker-rails', '~> 0.1.3'
gem 'bootstrap-select-rails', '~> 1.6', '>= 1.6.3'
#JQuery Rails
gem 'jquery-rails'

 gem 'rails_12factor', group: :production
# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.4.2', require: false

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end

group :development do
  # Access an interactive console on exception pages or by calling 'console' anywhere in the code.
  gem 'web-console', '>= 3.3.0'
  gem 'listen', '~> 3.2'
  gem 'pry'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
end

group :test do
  # Adds support for Capybara system testing and selenium driver
  gem 'capybara', '>= 2.15'
  gem 'selenium-webdriver'
  # Easy installation and use of web drivers to run system tests with browsers
  gem 'webdrivers'
  gem 'cucumber-rails', require: false
  gem 'database_cleaner'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

#HTTParty for RESTful API calls
gem 'httparty'


#Paperclip for storing files
gem 'paperclip'
gem "mongoid-paperclip", :require => "mongoid_paperclip"

gem "letter_opener", :group => :development

【问题讨论】:

devcenter.heroku.com/changelog-items/2306 【参考方案1】:

更多信息:

由于 nodejsruby 构建包已按此顺序在我的应用上设置:

$ heroku buildpacks
=== myapp Buildpack URLs
1. heroku/ruby
2. heroku/nodejs

以下命令heroku buildpacks:add heroku/nodejs --index 1 不起作用。

我必须使用以下命令删除它们:

heroku buildpacks:remove heroku/ruby
heroku buildpacks:remove heroku/nodejs

然后重新添加它们(按此顺序):

heroku buildpacks:add heroku/nodejs
heroku buildpacks:add heroku/ruby

最后通过我的package.json 在 Heroku 上指定一个节点版本:

   
      "engines": 
        "node": "12.16.2"
      
    

这个link 对解决我的问题也很有用。

【讨论】:

【参考方案2】:

似乎 Heroku 已经更新了他们在构建过程中使用的节点版本,因为我也收到了与 webpacker 相关的相同错误消息:

[4/4] Building fresh packages...
       error /tmp/build_1ea87a91/node_modules/@rails/webpacker/node_modules/node-sass: Command failed.
       Exit code: 1 

由于我的应用程序中的 rails/webpacker 4.3.0,我的部署失败。在朋友的帮助下,我通过升级到 webpacker 5.4.3 解决了这个问题。

您可以将 package.json 文件中的 webpacker 版本升级到 5.4.3,或者如果您使用 yarn,则运行以下命令:

yarn upgrade @rails/webpacker --latest

【讨论】:

我可以确认yarn upgrade @rails/webpacker --latest 工作正常并解决了我的问题。【参考方案3】:

我遇到了类似的问题,但通过以下步骤解决了。

    运行以下命令。 heroku buildpacks:add heroku/nodejs --index 1 在 package.json 中将节点版本从 16.x 更新为 12.16.2

【讨论】:

以上是关于项目场景: gyp verb check python checking for Python executable python2 in the PATH的主要内容,如果未能解决你的问题,请参考以下文章

成功解决gyp verb ensuring that file exists

无法在 heroku 上构建和部署 Rails 6.0.4.1 应用程序 - 引发 gyp verb cli 错误

项目构建工具CMake、GYP、GN

异常:关于node-gyp

npm 安装模块报node-gyp ERR!

gyp ERR!与node-pre-gyp ERR!