"AttributeError: 'module' object has no attribute 'getdefaultlocale'" on Python start

Matt Nordhoff mnordhoff at mattnordhoff.com
Tue Sep 9 09:37:20 CEST 2008


Barak, Ron wrote:
> Hi Fellow Pythonians,
>  
> I stated getting the following when starting Python (2.5.2 on Windows XP):
>  
> C:\Documents and Settings\RBARAK>python -v
> # installing zipimport hook
> import zipimport # builtin
> # installed zipimport hook
> # D:\Python25\lib\site.pyc matches D:\Python25\lib\site.py
> import site # precompiled from D:\Python25\lib\site.pyc
> # D:\Python25\lib\os.pyc matches D:\Python25\lib\os.py
> import os # precompiled from D:\Python25\lib\os.pyc
> import errno # builtin
> import nt # builtin
> # D:\Python25\lib\ntpath.pyc matches D:\Python25\lib\ntpath.py
> import ntpath # precompiled from D:\Python25\lib\ntpath.pyc
> # D:\Python25\lib\stat.pyc matches D:\Python25\lib\stat.py
> import stat # precompiled from D:\Python25\lib\stat.pyc
> # D:\Python25\lib\UserDict.pyc matches D:\Python25\lib\UserDict.py
> import UserDict # precompiled from D:\Python25\lib\UserDict.pyc
> # D:\Python25\lib\copy_reg.pyc matches D:\Python25\lib\copy_reg.py
> import copy_reg # precompiled from D:\Python25\lib\copy_reg.pyc
> # D:\Python25\lib\types.pyc matches D:\Python25\lib\types.py
> import types # precompiled from D:\Python25\lib\types.pyc
> import _types # builtin
> import locale # directory
> D:\Python25\Lib\site-packages\wx-2.8-msw-unicode\wx\locale
> import locale # precompiled from
> D:\Python25\Lib\site-packages\wx-2.8-msw-unicode\wx\locale\__init__.pyc

For some reason, when you run "import locale", it's importing wx.locale
instead of the "locale" module from the stdlib. However, I have no idea
why that would be happening... Did you do something to add wx to your
PYTHONPATH? Maybe do "import sys; print sys.path" or "import os; print
os.environ['PYTHONPATH']" to verify this.

(Hopefully someone more knowledgeable than me will come along soon.)

> # D:\Python25\lib\codecs.pyc matches D:\Python25\lib\codecs.py
> import codecs # precompiled from D:\Python25\lib\codecs.pyc
> import _codecs # builtin
> import encodings # directory D:\Python25\lib\encodings
> # D:\Python25\lib\encodings\__init__.pyc matches
> D:\Python25\lib\encodings\__init__.py
> import encodings # precompiled from D:\Python25\lib\encodings\__init__.pyc
> # D:\Python25\lib\encodings\aliases.pyc matches
> D:\Python25\lib\encodings\aliases.py
> import encodings.aliases # precompiled from
> D:\Python25\lib\encodings\aliases.pyc
> 'import site' failed; traceback:
> Traceback (most recent call last):
>   File "d:\Python25\lib\site.py", line 415, in <module>
>     main()
>   File "d:\Python25\lib\site.py", line 406, in main
>     aliasmbcs()
>   File "d:\Python25\lib\site.py", line 357, in aliasmbcs
>     enc = locale.getdefaultlocale()[1]
> AttributeError: 'module' object has no attribute 'getdefaultlocale'
> # D:\Python25\lib\warnings.pyc matches D:\Python25\lib\warnings.py
> import warnings # precompiled from D:\Python25\lib\warnings.pyc
> # D:\Python25\lib\linecache.pyc matches D:\Python25\lib\linecache.py
> import linecache # precompiled from D:\Python25\lib\linecache.pyc
> Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit
> (Intel)] on
> win32
> Type "help", "copyright", "credits" or "license" for more information.
>>>>
>  
> Has anyone else gotten this error ?
> Could anyone suggest a solution ?
>  
> Thanks,
> Ron.
-- 



More information about the Python-list mailing list