Bug report #19405

The python console does not run files with special characters in the filename (character encoding issue)

Added by Peter Bontinck over 6 years ago. Updated over 6 years ago.

Status:Open
Priority:Normal
Assignee:Salvatore Larosa
Category:PyQGIS Console
Affected QGIS version:3.2 Regression?:Yes
Operating System:Windows7 Easy fix?:Yes
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:27233

Description

1) python script file : C:\Desktop\french é ë ç\UploadScriptPy3.py

2) You can open to the file to edit in the build in editor, but when you puch "run script":

3) FileNotFoundError: [Errno 2] No such file or directory: b'C:/Desktop/french \xc3\xa9 \xc3\xab \xc3\xa7/UploadScriptPy3.py'

Looks like some character encoding issue: u'\french é ë ç\' becomes '/french \xc3\xa9 \xc3\xab \xc3\xa7/'

This was not a problem in QGIS2.18

screen.JPG - screenshot (57.9 KB) Peter Bontinck, 2018-07-13 11:35 AM

Capture.JPG (60.6 KB) Peter Bontinck, 2018-07-13 12:03 PM

History

#1 Updated by Salvatore Larosa over 6 years ago

Please can you provide the whole stacktrace of the error?
On master I cannot reproduce the issue.

#2 Updated by Peter Bontinck over 6 years ago

  • Assignee set to Salvatore Larosa
  • File screen.JPG added

thanks for the quick response,

i have this error on all my PC's (windows 7 and windows 10)

full stack trace:

Python Console
Use iface to access QGIS API interface or Type help(iface) for more info
exec(open('C:/Users/BQH8201/Desktop/french é ë ç/UploadScript.py'.encode('utf-8')).read())
Traceback (most recent call last):
File "C:\OSGEO4~1\apps\Python36\lib\code.py", line 91, in runcode
exec(code, self.locals)
File "<input>", line 1, in <module>
FileNotFoundError: [Errno 2] No such file or directory: b'C:/Users/BQH8201/Desktop/french \xc3\xa9 \xc3\xab \xc3\xa7/UploadScript.py'

#3 Updated by Salvatore Larosa over 6 years ago

the following command work for you:

exec(open('C:/Users/BQH8201/Desktop/french é ë ç/UploadScript.py').read())

#4 Updated by Peter Bontinck over 6 years ago

thanks,

This works indeed,
but is not automatically triggered when pushing the "run script" button in the python editor

Also available in: Atom PDF