Tag Archives: pyDev

Error in reading Chinese path of pydev in eclipse

Originally, I was thinking of organizing the cluttered code, sorting different functions into different py files and calling them in the main function, but as a result, Chinese characters appeared in the input path of the main function, and an error was reported.

SyntaxError: Non-UTF-8 code starting with ‘\xba’ in file D:\Python Projects\RidgeMorphology\src\ridgemorph.py on line 19, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

After debugging, the content seen is:

warning: Debugger speedups using cython not found. Run ‘”C:\Users\users\AppData\Local\Programs\Python\Python37\python.exe” “C:\Users\Jia\.p2\pool\plugins\org.python.pydev.core_6.4.3.201807050139\pysrc\setup_cython.py” build_ext –inplace’ to build.
pydev debugger: starting (pid: 6688)
Traceback (most recent call last):
File “C:\Users\users\.p2\pool\plugins\org.python.pydev.core_6.4.3.201807050139\pysrc\pydevd.py”, line 1715, in <module>
main()
File “C:\Users\users\.p2\pool\plugins\org.python.pydev.core_6.4.3.201807050139\pysrc\pydevd.py”, line 1709, in main
globals = debugger.run(setup[‘file’], None, None, is_module)
File “C:\Users\users\.p2\pool\plugins\org.python.pydev.core_6.4.3.201807050139\pysrc\pydevd.py”, line 1062, in run
return self._exec(is_module, entry_point_fn, module_name, file, globals, locals)
File “C:\Users\users\.p2\pool\plugins\org.python.pydev.core_6.4.3.201807050139\pysrc\pydevd.py”, line 1069, in _exec
pydev_imports.execfile(file, globals, locals) # execute the script
File “C:\Users\users\.p2\pool\plugins\org.python.pydev.core_6.4.3.201807050139\pysrc\_pydev_imps\_pydev_execfile.py”, line 20, in execfile
contents = stream.read()
File “C:\Users\users\AppData\Local\Programs\Python\Python37\lib\codecs.py”, line 322, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xba in position 515: invalid start byte

 

But I clearly defined the encoding when I defined the file: # -*- coding: utf-8 -*-

I did a lot of searching on the Internet, but I couldn’t find a solution, and then I had a sudden thought that it was a compiler problem

So I set the encoding format in the compiler to utf-8

Problem solving!

As a python rookie, I always look for problems at the code level when I encounter them, and errors caused by the compiler should not be ignored.