Search code examples
cocos2d-x

cocos installation: AttributeError: 'dict' object has no attribute 'has_key'


I am following the tutorial on my mac. I have all env paths set correctly but when I start a new project I am getting an error. I have 2 pythons installed 3.4 and 2.7; is it a reason why I have a problem?

I wrote:

cocos$ cocos new HelloWorld -p com.myname.HelloWorld -l cpp -d / Users/dev/cocos/cocosProjects/HelloWorld

and I received the following error:

Traceback (most recent call last): File "/Users/dev/cocos/cocos2d-x-3.10/tools/cocos2d-console/bin/cocos.py", line 904, in if not _check_python_version(): File "/Users/dev/cocos/cocos2d-x-3.10/tools/cocos2d-console/bin/cocos.py", line 868, in _check_python_version print(MultiLanguage.get_string('COCOS_PYTHON_VERSION_TIP_FMT') % (major_ver, minor_ver)) File "/Users/dev/cocos/cocos2d-x-3.10/tools/cocos2d-console/bin/MultiLanguage.py", line 52, in get_string fmt = cls.get_instance().get_current_string(key) File "/Users/dev/cocos/cocos2d-x-3.10/tools/cocos2d-console/bin/MultiLanguage.py", line 46, in get_instance cls.instance = MultiLanguage() File "/Users/dev/cocos/cocos2d-x-3.10/tools/cocos2d-console/bin/MultiLanguage.py", line 100, in init if self.cfg_info.has_key(cur_lang_key): AttributeError: 'dict' object has no attribute 'has_key'


Solution

  • I installed python2.7.11 once again and since then I could use cocos new to build a new project; aliasing python as python2 did not work before; I still have access to my 3.4 version for other applications but 2.7 is my default one which was the problem before. I hope it will help those who have similar problem.

    thank you all for having a look