Opened 12 years ago
Last modified 11 years ago
#1941 closed defect
wxGUI fails with Japanese locale --> mixed Python installs on Windows — at Version 25
Reported by: | venkat | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | 7.0.0 |
Component: | wxGUI | Version: | svn-trunk |
Keywords: | wingrass | Cc: | |
CPU: | x86-32 | Platform: | MSWindows 7 |
Description (last modified by )
I get following error with the wxGUI while running GRASS7-svn when selecting modules form the menu. on Windows-7 in Japanese locale. I guess it is related to utf-8 encoding.
Traceback (most recent call last): File "C:\Program Files\GRASS GIS 7.0.svn\etc\gui\wxpython\lmgr\frame.py", line 737, in OnMenuCmd cmd = self.GetMenuCmd(event) File "C:\Program Files\GRASS GIS 7.0.svn\etc\gui\wxpython\lmgr\frame.py", line 722, in GetMenuCmd input = GUI().GetCommandInputMapParamKey(cmdlist[0]) File "C:\Program Files\GRASS GIS 7.0.svn\etc\gui\wxpython\gui_core\forms.py", line 2301, in GetCommandInputMapParamKey gtask.get_interface_description(cmd).decode(enc).encode('utf -8'))) UnicodeDecodeError : 'cp932' codec can't decode bytes in position 7074-7075: illegal multibyte sequence
Change History (28)
comment:1 by , 12 years ago
Summary: | wxGUI error → wxGUI fails with Japanese locale |
---|
comment:2 by , 12 years ago
Keywords: | wingrass added |
---|
comment:3 by , 12 years ago
This issue seems to have been fixed in GRASS-6.4 but I think still remains in GRASS-7.0.
comment:5 by , 12 years ago
by , 12 years ago
Attachment: | patch_for_ticket_1941.patch added |
---|
follow-up: 7 comment:6 by , 12 years ago
I encounter similar problem.
I suggest modifying the sementics of gtask.get_interface_description() to return xml in "utf-8" encoding. see attachment "patch_for_ticket_1941.patch".
Rational:
- The following code segment in task.py and forms.py is too limited because ("cp936","cp932", etc) need similar converting:
enc = locale.getdefaultlocale()[1] if enc and enc.lower() == "cp932": p = re.compile('encoding="' + enc + '"', re.IGNORECASE) tree = etree.fromstring(p.sub('encoding="utf-8"', get_interface_description(name).decode(enc).encode("utf-8"))) else: tree = etree.fromstring(get_interface_description(name))
- Any where the gtask.get_interface_description() is called, the "convert-to-utf8" is needed;
- Properly constructed interface description text is xml text with proper <?xml ... encoding="some-text-encoding"?> statement, extract text encoding schema from these xml text is more rational than extract enc from locale package.
follow-up: 8 comment:7 by , 12 years ago
Replying to improgrammer:
I encounter similar problem.
I suggest modifying the sementics of gtask.get_interface_description() to return xml in "utf-8" encoding. see attachment "patch_for_ticket_1941.patch".
Rational:
- The following code segment in task.py and forms.py is too limited because ("cp936","cp932", etc) need similar converting:
enc = locale.getdefaultlocale()[1] if enc and enc.lower() == "cp932": p = re.compile('encoding="' + enc + '"', re.IGNORECASE) tree = etree.fromstring(p.sub('encoding="utf-8"', get_interface_description(name).decode(enc).encode("utf-8"))) else: tree = etree.fromstring(get_interface_description(name))- Any where the gtask.get_interface_description() is called, the "convert-to-utf8" is needed;
- Properly constructed interface description text is xml text with proper <?xml ... encoding="some-text-encoding"?> statement, extract text encoding schema from these xml text is more rational than extract enc from locale package.
Can someone else working in a Japanese Windows environment test this patch ?
follow-up: 9 comment:8 by , 12 years ago
Replying to mlennert: ...
Can someone else working in a Japanese Windows environment test this patch ?
Proposal: Since it so much easier to update winGRASS via installer, I would suggest that we submit the patch to SVN and test from there. In the worst case we revert after 24hs/whatever time.
follow-up: 10 comment:9 by , 12 years ago
Replying to neteler:
Replying to mlennert: ...
Can someone else working in a Japanese Windows environment test this patch ?
Proposal: Since it so much easier to update winGRASS via installer, I would suggest that we submit the patch to SVN and test from there. In the worst case we revert after 24hs/whatever time.
Done in r57501. Please test!
comment:10 by , 12 years ago
Replying to annakrat:
Replying to mlennert: ...
Can someone else working in a Japanese Windows environment test this patch ?
Done in r57501. Please test!
The related winGRASS 7 binary is now available here: http://wingrass.fsv.cvut.cz/grass70/
as well as in OSGEo4W.
by , 12 years ago
Attachment: | wxgui_error.png added |
---|
follow-up: 12 comment:11 by , 12 years ago
tried with WinGRASS-7.0.svn-r57518-685-Setup.exe from http://wingrass.fsv.cvut.cz/grass70/ but this gives me
ImportError: No module named gis when I try to start the wxGUI. Details in the attachment.
Venka
follow-up: 13 comment:12 by , 12 years ago
Replying to venkat:
tried with WinGRASS-7.0.svn-r57518-685-Setup.exe from http://wingrass.fsv.cvut.cz/grass70/ but this gives me
ImportError: No module named gis when I try to start the wxGUI. Details in the attachment.
You seem to have a problem with ctypes. I moved importing temporal gis library (which apparently uses ctypes) so that wxGUI should at least start.
comment:13 by , 12 years ago
Replying to annakrat:
Replying to venkat:
tried with WinGRASS-7.0.svn-r57518-685-Setup.exe from http://wingrass.fsv.cvut.cz/grass70/ but this gives me
ImportError: No module named gis when I try to start the wxGUI. Details in the attachment.
You seem to have a problem with ctypes. I moved importing temporal gis library (which apparently uses ctypes) so that wxGUI should at least start.
Venka,
Have you been able to test these last changes ?
Moritz
follow-up: 15 comment:14 by , 11 years ago
Tried with WinGRASS-7.0.svn-r57622-697-Setup.exe and get errors as shown in the attachment.
Thanks
Venka
follow-up: 16 comment:15 by , 11 years ago
follow-up: 17 comment:16 by , 11 years ago
Replying to annakrat:
Anybody has an idea how to fix this annoying MAXREPEAT problem?
Did you try this?
follow-up: 18 comment:17 by , 11 years ago
Replying to neteler:
Replying to annakrat:
Anybody has an idea how to fix this annoying MAXREPEAT problem?
Did you try this?
Usually it's caused by Python installed together with Esri ArcGIS. The newest version of ArcGIS 10.2 still comes with Python 2.7.3. It would be good to find solution on our side without overwriting system-installed Python.
follow-up: 19 comment:18 by , 11 years ago
Replying to martinl:
Usually it's caused by Python installed together with Esri ArcGIS. The newest version of ArcGIS 10.2 still comes with Python 2.7.3. It would be good to find solution on our side without overwriting system-installed Python.
2.7.3 should be fine for GRASS, right? So the solution should be to detect that the "system" Python is sufficient and not try to use the bundled Python (i.e. don't set PYTHONHOME, set GRASS_PYTHON to point to the system version, etc).
AFAICT, the issue is that the system python27.dll (from Windows/System32
or Windows/SysWOW64
) is being used, but PYTHONHOME points to the bundled version of the Python standard library.
If you can start a Python shell using the GRASS Python, you can use Process Explorer to view the list of DLLs which are actually being used by that process. AFAIK, System32/SysWOW64 take precedence over everything except the directory containing the exe, and %PATH% comes last.
follow-ups: 21 24 comment:19 by , 11 years ago
Replying to glynn:
Replying to martinl:
Usually it's caused by Python installed together with Esri ArcGIS. The newest version of ArcGIS 10.2 still comes with Python 2.7.3. It would be good to find solution on our side without overwriting system-installed Python.
2.7.3 should be fine for GRASS, right? So the solution should be to detect that the
No, the problem still remains. Note that we have this problem only with standalone installer not with osgeo4w installer.
"system" Python is sufficient and not try to use the bundled Python (i.e. don't set PYTHONHOME, set GRASS_PYTHON to point to the system version, etc).
But then we will have problem with other python packages (GRASS dependecies) which are installed through osgeo4w environment as python-matplotlib
or python-numpy
, right? Version of "system" python will be most probably different from the python version available in osgeo4w environment.
AFAICT, the issue is that the system python27.dll (from
Windows/System32
orWindows/SysWOW64
) is being used, but PYTHONHOME points to the bundled version of the Python standard library.If you can start a Python shell using the GRASS Python, you can use Process Explorer to view the list of DLLs which are actually being used by that process. AFAIK, System32/SysWOW64 take precedence over everything except the directory containing the exe, and %PATH% comes last.
Strangely C:\Program Files (x86)\GRASS GIS 7.0.svn\extrabin\python.exe
launches python 2.7.3 (same as system python from C:\Python27\ArcGIS 10.2
)! When launching C:\osgeo4w\bin\python.exe
I got expected version of python, so 2.7.4 (current osgeo4w python version). This partly explains the fact that we have this problem only with standalone installer.
Right, when I launch python.exe
which comes with standalone installer it points to C:Windows\SysWOW64\python27.dll
. When I launch python.exe
from C:\OSGeo4W\bin
it points to the right dll file, ie. C:\OSGeo4W\bin\python27.dll
.
comment:20 by , 11 years ago
I think that the Python launcher might be the best solution for this. See the experiments with different combinations of Python versions at [1].
[1] http://lists.osgeo.org/pipermail/grass-dev/2013-July/065197.html
follow-ups: 22 23 comment:21 by , 11 years ago
Replying to martinl:
Right, when I launch
python.exe
which comes with standalone installer it points toC:Windows\SysWOW64\python27.dll
. When I launchpython.exe
fromC:\OSGeo4W\bin
it points to the right dll file, ie.C:\OSGeo4W\bin\python27.dll
.
Ah, OK, it's probably caused by the fact that the standalone installer puts python27.dll
to the different directory (ie. extralib
) compared to python.exe
(extrabin
). Directory extralib
is in the path source:grass/trunk/mswindows/env.bat#L17, but it's probably not enough. The problem could be solved by moving python27.dll
to extrabin
. Then we could probably move all DLL files to extrabin
and get rid of this directory. It's comment practice to have DLL files together with EXE files in the same directory. I don't know why the standalone installer separates them to the two different directories, ie. extrabin
and extralib
.
comment:22 by , 11 years ago
Replying to martinl:
Replying to martinl:
Right, when I launch
python.exe
which comes with standalone installer it points toC:Windows\SysWOW64\python27.dll
. When I launchpython.exe
fromC:\OSGeo4W\bin
it points to the right dll file, ie.C:\OSGeo4W\bin\python27.dll
.Ah, OK, it's probably caused by the fact that the standalone installer puts
python27.dll
to the different directory (ie.extralib
) compared topython.exe
(extrabin
). Directoryextralib
is in the path source:grass/trunk/mswindows/env.bat#L17, but it's probably not enough. The problem could be solved by movingpython27.dll
toextrabin
. Then we could probably move all DLL files toextrabin
and get rid of this directory. It's comment practice to have DLL files together with EXE files in the same directory. I don't know why the standalone installer separates them to the two different directories, ie.extrabin
andextralib
.
Try it, but ISTR that there is also an issue with the Windows registry, i.e. that the dlls called depend on registry entries (I think that this came up as a problem at least in the case of python scripts called from python scripts).
comment:23 by , 11 years ago
Replying to martinl:
Ah, OK, it's probably caused by the fact that the standalone installer puts
python27.dll
to the different directory (ie.extralib
) compared topython.exe
(extrabin
). Directoryextralib
is in the path source:grass/trunk/mswindows/env.bat#L17, but it's probably not enough. The problem could be solved by movingpython27.dll
toextrabin
. Then we could probably move all DLL files toextrabin
and get rid of this directory. It's comment practice to have DLL files together with EXE files in the same directory.
that could be the clue. same directory could work.
I don't know why the standalone installer separates them to the two different directories, ie.
extrabin
andextralib
.
also no idea or memory here on my side. since I'm involved in the winGRASS, the separation in extrabin
and extralib
was always there.
comment:24 by , 11 years ago
Replying to martinl:
"system" Python is sufficient and not try to use the bundled Python (i.e. don't set PYTHONHOME, set GRASS_PYTHON to point to the system version, etc).
But then we will have problem with other python packages (GRASS dependecies) which are installed through osgeo4w environment as
python-matplotlib
orpython-numpy
, right? Version of "system" python will be most probably different from the python version available in osgeo4w environment.
Add-on packages don't normally care about the minor version, so a package built for 2.7 should work with 2.7.<anything>.
This doesn't apply to sre_*.py; modules which are part of the base Python distribution don't expect to be used with anything other than the exact Python version of which they are part.
Right, when I launch
python.exe
which comes with standalone installer it points toC:Windows\SysWOW64\python27.dll
. When I launchpython.exe
fromC:\OSGeo4W\bin
it points to the right dll file, ie.C:\OSGeo4W\bin\python27.dll
.
That will be because the OSGeo4W version has its python27.dll in the same directory as python.exe. The directory containing the EXE comes first, before the system directories; %PATH% comes last.
comment:25 by , 11 years ago
Description: | modified (diff) |
---|---|
Summary: | wxGUI fails with Japanese locale → wxGUI fails with Japanese locale --> mixed Python installs on Windows |
Two tickets related to cp932: