0

When i tried to run following python code:
setlocale(locale.LC_ALL,"")
print getlocale()
The result is that it works fine if i run the script from Terminal.
But in eclipse/pydev with the same python compiler(python 2.7),it always return (none,none), any idea?

1 Answers1

0

As you have already guessed from our conversation in the comments, this behavior is related to the environment. If you run Eclipse from the Terminal, you will get the same results you get when running Python directly from the Terminal.

So, your program is actually working fine. Depending on what you want to do, you don't need to worry about anything.

However, if you want to reconfigure your environment (system-wide or for all programs launched from the GUI, for example), you can do that in the appropriate files, using this answer as a guide.

For example, you may want to set the variables LANG and LC_ALL in one of those files, mimicking the configuration that is shown when you run the command locale from the Terminal. Assuming you want en_US with UTF-8, that added lines would look like:

export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
Community
  • 1
  • 1
igorrs
  • 350
  • 1
  • 7
  • After reading the post, can you help me to figure out what should i add to the path? – Comp Ironman Apr 03 '14 at 09:29
  • In this case, you don't need to change PATH. You may want to set some environment variables to adjust your locale settings. You can see the settings from the Terminal by running the `locale` command. – igorrs Apr 03 '14 at 09:37
  • I use "launchctl setenv LANG $LANG" and it works now. – Comp Ironman Apr 03 '14 at 09:52