cocos执行tolua/genbindings.py文件,错误搜集:

1、
PYTHON_BIN not defined, use current python.
这个不是错误

2、
llvm toolchain not found!
path: /Users/staff/Documents/worksoft/android-ndk-r10e/toolchains/llvm-3.3/prebuilt/darwin-x86 or path: /Users/staff/Documents/worksoft/android-ndk-r10e/toolchains/llvm-3.3/prebuilt/darwin-x86_64 are not valid!
这个问题因为android-ndk-r10e这个ndk不能用来生成tolua文件,必须使用android-ndk-r9b这个版本的ndk,下面这句话可以在
quick(泰然社区维护的版本)中tolua目录下的readme文件中找到,但是cocos中并没有说明。
Make sure that you have installed `android-ndk-r9b`.
针对这里的修改我们可以直接写死ndk路径,因为编译还是需要android-ndk-r10e的,我的修改:
找到下面这个函数:
def _check_ndk_root_env():
''' Checking the environment NDK_ROOT, which will be used for building
'''

try:
# 这里直接写死
# NDK_ROOT = os.environ['NDK_ROOT']
NDK_ROOT = "/Users/staff/Documents/worksoft/android-ndk-r9"
except Exception:
print "NDK_ROOT not defined. Please define NDK_ROOT in your environment."
sys.exit(1)

return NDK_ROOT
下面是quick中的tolua目录下的readme文件部分说明:
On MAC:
----------

* The OSX 10.9 has a built-in python2.7 and if your os don't have python2.7 then use [Homebrew](http://brew.sh/) to install the python and use pip install the python dependencies.
<pre>
brew install python
</pre>

* Install python dependices by pip.
<pre>
sudo easy_install pip
sudo pip install PyYAML
sudo pip install Cheetah
</pre>

* Download [64bit ndk-r9b-x86_64](http://dl.google.com/android/ndk/android-ndk-r9b-darwin-x86_64.tar.bz2) from [google](http://developer.android.com/tools/sdk/ndk/index.html)
* Run
<pre>
export NDK_ROOT=/path/to/android-ndk-r9b
./genbindings.py
</pre>


3、
mportError: No module named yaml
我按照上面的说明,安装了yaml模块,但是总是说找不到这个模块,这个是路径问题,因为我从新安装了python,然而:
这里使用的python是系统默认的#!/usr/bin/python,而不是我从新安装的,这里只需要修改为#!/usr/bin/env python即可,两种是有区别的。当然还可以其他方式解决,如直接把yaml模块的路径直接
import sys
sys.path.append('/xxx/xxxxx/') 加进去也行。

原文地址:https://www.cnblogs.com/ZhYQ-Note/p/5939783.html