Error when running "cocos" in cmd/terminal

Hi all, I cloned the github repository of cocos2d-x and followed the instructions in the README, and all went smoothly. But when invoking “cocos” in the cmd/terminal (since I have the same error in both mac and windows), this error is thrown:

Traceback (most recent call last):
File “/Users/nmesselmani/Documents/GameDev/SDK/cocos2D-x/tools/cocos2d-console/bin/cocos.py”, line 22, in
import cocos_project
File “/Users/nmesselmani/Documents/GameDev/SDK/cocos2D-x/tools/cocos2d-console/bin/cocos_project.py”, line 4, in
import cocos
File “/Users/nmesselmani/Documents/GameDev/SDK/cocos2D-x/tools/cocos2d-console/bin/cocos.py”, line 874, in
language, encoding = locale.getlocale()
File “/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py”, line 562, in getlocale
return _parse_localename(localename)
File “/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py”, line 475, in _parse_localename
raise ValueError, ‘unknown locale: %s’ % localename
ValueError: unknown locale: UTF-8

What can I do to make cocos work?
Thank you all.

Hello again, I tried a few things, and nothing worked. I uninstalled python, removed cocos from system PATH, git cloned the latest version, re-installed pythnon 2.7 run download-deps and setup. and still the same error is shown… I am a bit confused about this…

You need to set your locale to the correct format. UTF-8 is unknown.
On Windows(assuming you have Win7):
http://windows.microsoft.com/en-us/windows/change-system-locale#1TC=windows-7

On OS X type in “locale” in your terminal, and you should see the settings.

Make the following changes, if some are not set correctly:

LC_ALL=en_US.UTF-8
LANG=en_US.UTF-8
2 Likes

Thank you iQD I reset the locale things and it worked. Thanks a lot :smiley: