You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

安装Hyperledger Composer开发工具报错:找不到Python2.7.9可执行文件

Fixing node-gyp Python Error When Installing Hyperledger Composer CLI

Hey there, let's tackle that frustrating gyp ERR! configure error you're seeing when running npm install -g composer-cli. The root issue is that node-gyp (a tool npm uses to build native modules) requires Python 2.7.x (not Python 3.x), and it's specifically looking for version 2.7.9—though most 2.7.x releases will work just fine. Here's how to fix it:

Option 1: If You Already Have Python 2.7 Installed

First, confirm where your Python 2.7 is located by running this in your terminal:

which python2.7

This will output a path like /usr/bin/python2.7 or /usr/local/bin/python2.7.

Temporary Fix (Only for Current Terminal Session)

Set the PYTHON environment variable temporarily, then run the install command again:

export PYTHON=/path/to/your/python2.7
npm install -g composer-cli

Replace /path/to/your/python2.7 with the actual path from the which command.

Permanent Fix (Applies to All Future Terminal Sessions)

Add the environment variable to your shell config file so you don't have to set it every time:

  • If you use Bash:
    1. Open your ~/.bash_profile or ~/.bashrc file in a text editor.
    2. Add this line (replace the path with your actual Python 2.7 path):
      export PYTHON=/usr/bin/python2.7
      
    3. Save the file and run source ~/.bash_profile (or source ~/.bashrc) to apply the changes.
  • If you use Zsh:
    1. Open your ~/.zshrc file in a text editor.
    2. Add the same export PYTHON=... line as above.
    3. Save and run source ~/.zshrc to apply.

Option 2: If You Don't Have Python 2.7 Installed

On macOS

  • Use Homebrew to install Python 2.7 (if you have Homebrew installed):
    brew install python@2
    
    After installation, the path will typically be /usr/local/bin/python2.7—use this path in the steps from Option 1.
  • Alternatively, download the official Python 2.7 installer (grab the latest 2.7.x release, like 2.7.18), install it, then find its installation path (usually /usr/bin/python2.7).

Quick Alternative: Specify Python Directly in the npm Command

You can also skip setting environment variables entirely by passing the Python path directly to npm:

npm install -g composer-cli --python=/path/to/your/python2.7

Bonus: Fix Additional node-gyp Dependencies

If you run into further errors after fixing the Python issue, node-gyp might also need build tools like make or gcc. On macOS, install the Xcode Command Line Tools with:

xcode-select --install

Give these steps a go, and you should be able to get the Hyperledger Composer CLI installed without hitting that Python error!

内容的提问来源于stack exchange,提问作者Vikas Banage

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 04:00:54