Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3752944
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T09:18:57+00:00 2026-05-19T09:18:57+00:00

I wrote a simple wxPython app which I package with py2app, turning it into

  • 0

I wrote a simple wxPython app which I package with py2app, turning it into a self-contained double-clickable .app bundle which I can give to other people to run.

My app uses some locale-specific settings — specifically, it wants to parse dates in text form — so it lets the user specify what locale to use, and it calls locale.getdefaultlocale() to prepopulate this choice.

I tested this by running the python code directly (in the system-installed Python, not packaged) and it worked fine, then I packaged it with py2app and tested the resulting self-contained app with “open dist/foo.app” and it worked fine. Then I gave it to somebody else and they complained it immediately threw an exception; I tried double-clicking my .app in the Finder and lo and behold, locale.getdefaultlocale() is indeed returning None (the exception resulted from me making method calls on that object).

I wrote a simple test app that dumps the environment and the value of locale.getdefaultlocale(), and ran it in the same 3 environments. Results:
– invoke directly from Terminal as “python envdump.py”: dumps my full environment
– package with py2app, invoke from Terminal as “open dist/envdump.app”: dumps my full environment
– invoke that same dist/envdump.app by opening it from Finder: environment is much more limited, and yes, locale.getdefaultlocale() returns (None, None), because LANG is unset.

The complete list of environment variables set by the Finder is: ARGVZERO, Apple_PubSub_Socket_Render, COMMAND_MODE, DISPLAY, EXECUTABLEPAT, HOME, LOGNAME, PATH, PYTHONPATH, RESOURCEPATH, SHELL, SSH_AUTH_SOCK, TMPDIR,USER,__CF_USER_TEXT_ENCODING.

I can easily make my code tolerate the lack of LANG/locale.getdefaultlocale(), but I’d like to get that information somehow.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T09:18:58+00:00Added an answer on May 19, 2026 at 9:18 am

    The values for environment variables for applications launched (by double-clicking, say) are not the same as when run under a terminal window shell. There is a way to specify those by creating ~/.MacOSX/environment.plist: see here for more details. But that’s probably not what you want to do. If you need to create a default for your app, you can add it to the app’s plist as described here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote a simple web service in C# using SharpDevelop (which I just got
I wrote a simple javascript image rotator which picks a random image on each
I have a simple Google App Engine app, that I wrote using ordinary strings.
I wrote a simple batch file as a PowerShell script, and I am getting
I wrote a simple tool to generate a DBUnit XML dataset using queries that
I wrote a simple Windows Forms program in C#. I want to be able
I needed some simple string encryption, so I wrote the following code (with a
I wrote a wxPython program that I am translating to wxWidgets. The program has
I wrote simple NMEA parser and I'm reading latitude and longitude from GPS. Values
I wrote simple code to open a Word file (.docx) and set properties for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.