编译node.js出现“NameError:全局名称”文件未定义“

我有python2和python3,我运行./configure和它的作品。但我运行make,

 make -C out BUILDTYPE =释放V = 1

 make [1]:进入目录`/ home / colin4124 / MyProgram / node / out'
   LD_LIBRARY_PATH = /家庭/ colin4124 / MyProgram /节点/出/释放/ lib.host:/家庭/ colin4124 / MyProgra>米/节点/出/释放/ lib.target:$ LD_LIBRARY_PATH; 导出LD_LIBRARY_PATH;  cd ../deps/v8/tools/gyp;  mkdir -p / home / colin4124 / MyProgram / node / out / Release / obj / gen;  python ../../tools/gen-postmortem-metadata.py“/home/colin4124/MyProgram/node/out/Release/obj/gen/debug-support.cc”../../src/objects。 h ../../src/objects-inl.h
回溯(最近一次通话最后):
  文件“../../tools/gen-postmortem-metadata.py”,行479,in 
     emit_config();
  文件“../../tools/gen-postmortem-metadata.py”,第432行,在emit_config
     out = file(sys.argv [1],'w');
 NameError:未定义全局名称“文件”
 make [1]:*** [/home/colin4124/MyProgram/node/out/Release/obj/gen/debug-support.cc]错误1
 make [1]:离开目录`/ home / colin4124 / MyProgram / node / out'
 make:*** [node]错误2

我怎么能解决它,认为你!

看起来你的默认Python是3.x,但是Node构build脚本需要Python 2.x。

根据这些说明,您可以通过设置PYTHON环境variables来指向您的Python 2可执行文件来修复它:

 export PYTHON=`which python2` 

这是因为你的默认pythonpython3.x 。 Node.js推荐使用python2.6 / python2.7来编译源代码。
尝试检查您的python命令通过:

 ls -l /usr/bin/python 

它会显示lrwxrwxrwx 1 root root 9 Apr 3 15:46 /usr/bin/python -> python3

要将python2.7作为默认的python命令使用:

 sudo ln -sf `which python2.7` `which python` ls -l /usr/bin/python 

现在应该是lrwxrwxrwx 1 root root 9 Apr 3 15:46 /usr/bin/python -> python2.7