Traceback Error from Python2.7 and 3.3 Interactive Shell Prompt

Posted by promanelka on 2014-02-19 07:56

Just successfully activated my ActiveState Komodo 8.x and tried to write my first interactive shell program. But when I navigated to Tools -> Interactive Shell -> Start New Python3 Shell, viola! I get series of traceback something looking like:

Traceback (most recent call last):
File "/root/Komodo-IDE-8/lib/support/dbgp/bin/py3_dbgp", line 305, in
sys.exit( main(sys.argv) )
File "/root/Komodo-IDE-8/lib/support/dbgp/bin/py3_dbgp", line 169, in main
File "/root/Komodo-IDE-8/lib/support/dbgp/bin/py3_dbgp", line 151, in _fixencoding
codeset = locale.getdefaultlocale()[1]
File "/usr/local/lib/python3.3/", line 505, in getdefaultlocale
return _parse_localename(localename)
File "/usr/local/lib/python3.3/", line 433, in _parse_localename
raise ValueError('unknown locale: %s' % localename)
ValueError: unknown locale: en_NG

Decided to pay the first file a visit (cos when you use Linux you need to learn to tweak some things right!) that is : "/root/Komodo-IDE-8/lib/support/dbgp/bin/py3_dbgp" ,
it started with : #!/usr/bin/env python , then tried running `python' in BASH but Python2.7 and not 3.3 started!

I was left with just one more tweak so I decided to unalias python from Python2.7 well it didn't work cos the alias my Python3.3 has is 'python3'.

Not sure what to do next, so I humbly implore the community to please help me out this.

Muchas Gracias! (I don't speak Spanish :-) )

ActiveState Staff
Wed, 2014-02-19 09:01

"python" should be left to alias to Python2. For dis-ambiguation, and because it's treated as a different language, Python3 should be run as "python3".

Under bash, what you get when you run "python" has everything to do with your $PATH settings, and it's correct for it to give you Python2, as noted above. That doesn't mean the shebang line is incorrect. A shebang is just a short-cut, and is only used if another Python or Python3 hasn't already been specified in context or in the command. Code which is common to Python2/Python3 will most likely have (Python2) python noted in the shebang line.

The actual trace-back is a long-time Python core limitation/bug:
It happens because Python does not recognize the Nigerian English localization. If that localization is unexpected, you might want to investigate where it was set. As noted in the bug ticket you can re-set the localization on the fly in your code with "LANG=". For a list of localizations/mappings known to Python, see in $PythonInstallDir/lib/python$version.