Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v.clean UnicodeDecodeError when special character (German Umlaute) in path #29845

Closed
qgib opened this issue May 9, 2019 · 4 comments
Closed
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Feedback Waiting on the submitter for answers High Priority Processing Relating to QGIS Processing framework or individual Processing algorithms

Comments

@qgib
Copy link
Contributor

qgib commented May 9, 2019

Author Name: Wolfgang Meinolf (Wolfgang Meinolf)
Original Redmine Issue: 22031
Affected QGIS version: 3.6.2
Redmine category:processing/grass


v.clean stops processing with following error statement:

Traceback (most recent call last):
File "C:/OSGEO41/apps/qgis/./python/plugins\processing\algs\grass7\Grass7Algorithm.py", line 427, in processAlgorithm
Grass7Utils.executeGrass(self.commands, feedback, self.outputCommands)
File "C:/OSGEO4
1/apps/qgis/./python/plugins\processing\algs\grass7\Grass7Utils.py", line 393, in executeGrass
for line in iter(proc.stdout.readline, ''):
File "C:\OSGEO4~1\apps\Python37\lib\encodings\cp1252.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 179: character maps to

Path to .qgz and .gpkg files contains the word Thüringen(C:\User.........\Work\Thüringen\1905...). Once, the path name is changed to Thueringen C:\User.........\Work\Thueringen\190508 Neue Analysegebiete, no error occurrs.

@qgib
Copy link
Contributor Author

qgib commented May 9, 2019

Author Name: Giovanni Manghi (@gioman)


Duplicate of #29712 ?


  • status_id was changed from Open to Feedback

@qgib qgib added Feedback Waiting on the submitter for answers Bug Either a bug report, or a bug fix. Let's hope for the latter! High Priority GRASS labels May 25, 2019
@alexbruy alexbruy added Processing Relating to QGIS Processing framework or individual Processing algorithms and removed GRASS labels Jun 22, 2019
@Labros89
Copy link

I faced similar problems, I changed the language from regional settings in Windows but still I cannot run the tools from GRASS toolbox. Actually, I got the following message:
INFO GRASS GIS 7 execution console output
Traceback (most recent call last):

          File "C:\OSGEO4~1\apps\grass\grass78\etc\grass78.py", line 2216, in 
         
          main()
         
          File "C:\OSGEO4~1\apps\grass\grass78\etc\grass78.py", line 2092, in main
         
          create_initial_gisrc(gisrc)
         
          File "C:\OSGEO4~1\apps\grass\grass78\etc\grass78.py", line 728, in create_initial_gisrc
         
          writefile(filename, s)
         
          File "C:\OSGEO4~1\apps\grass\grass78\etc\grass78.py", line 225, in writefile
         
          f.write(s)
         
          File "C:\OSGEO4~1\apps\Python37\lib\encodings\cp1252.py", line 19, in encode
         
          return codecs.charmap_encode(input,self.errors,encoding_table)[0]
         
         UnicodeEncodeError: 'charmap' codec can't encode characters in position 34-40: character maps to 
         
         Press any key to continue . . . 
         
         Traceback (most recent call last):
         File "C:\OSGEO4~1\apps\grass\grass78\etc\grass78.py", line 2216, in 
         main()
         File "C:\OSGEO4~1\apps\grass\grass78\etc\grass78.py", line 2092, in main
         create_initial_gisrc(gisrc)
         File "C:\OSGEO4~1\apps\grass\grass78\etc\grass78.py", line 728, in create_initial_gisrc
         writefile(filename, s)
         File "C:\OSGEO4~1\apps\grass\grass78\etc\grass78.py", line 225, in writefile
         f.write(s)
         File "C:\OSGEO4~1\apps\Python37\lib\encodings\cp1252.py", line 19, in encode
         return codecs.charmap_encode(input,self.errors,encoding_table)[0]
         UnicodeEncodeError: 'charmap' codec can't encode characters in position 34-40: character maps to 
         Press any key to continue . . .

I tried to save the output without spaces etc but again it does not work.

Do you know how can I fix it?

@gioman
Copy link
Contributor

gioman commented Aug 5, 2020

v.clean stops processing with following error statement:

works fine on QGIS 3.10.8 in german on a win 10 system in german.

@gioman gioman closed this as completed Aug 5, 2020
@softark
Copy link

softark commented Jul 21, 2021

I got the same issue with QGIS 3.20 that is shipped with GRASS 7.8.5. The modules that would fail are "r.sun.incidout", "r.sun.insoltime", "r.sunhours", and others which create an internal temporary shell script file (batch job file) to execute some GRASS functions. There's no way in which the user can touch the encode of that temporary file. So, "don't use non-ascii" is not a helpful advice.

Traceback (most recent call last):
File "C:\OSGew4W/QGIS/apps/qgis/./python/plugins\processing\algs\grass7\Grass7Algorithm.py", line 433, in processAlgorithm
Grass7Utils.executeGrass(self.commands, feedback, self.outputCommands)
File "C:\OSGew4W/QGIS/apps/qgis/./python/plugins\processing\algs\grass7\Grass7Utils.py", line 397, in executeGrass
for line in iter(proc.stdout.readline, ''):
UnicodeDecodeError: 'cp932' codec can't decode byte 0x84 in position 35: illegal multibyte sequence

The environment is Windows 10 Professional 64-bit. "cp932" is "Shift-JIS" used in Japanese version.

I've checked "Grass7Utils.py" and found that the error occurs in the following way:

  1. executeGrass() is called. (line 371)
  2. in executeGrass(), prepareGrassExecution() is called (line 374)
  3. in prepareGrassExecution(), createGrassBachJobFileFromGrassCommand() is called (line 362)
  4. in createGrassBachJobFileFromGrassCommand(), a batch job file is automatically created.
  5. in executeGrass(), the batch job file is executed (line 387)
  6. and the error occurs with "proc.stdout.readline" !! (line 397)

So, I have to say it again, "Be careful about the path name" or "Don't use non-ascii characters" are not helpful at all in this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Feedback Waiting on the submitter for answers High Priority Processing Relating to QGIS Processing framework or individual Processing algorithms
Projects
None yet
Development

No branches or pull requests

5 participants