3

I have Django server running locally from quite some time. Suddenly today I started seeing error when runnign debug mode. it works fine in norrmal mode.

I tried including utf-8 in manage.py but still I see error

pydev debugger: process 10424 is connecting

Connected to pydev debugger (build 192.6603.34)
pydev debugger: process 10425 is connecting

Traceback (most recent call last):
  File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 2066, in <module>
    main()
  File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 2060, in main
    globals = debugger.run(setup['file'], None, None, is_module)
  File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 1411, in run
    return self._exec(is_module, entry_point_fn, module_name, file, globals, locals)
  File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 1418, in _exec
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python", line 1
SyntaxError: Non-ASCII character '\xcf' in file /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python on line 1, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details```


I expect it to run on debug mode. it already bloked me 1/2 day. Please help if you already have seen this issue or know how to fix this.
Raj
  • 368
  • 1
  • 5
  • 17
  • I tried and reinstalled pycharm too. I don't know where is this non-ascii character – Raj Oct 30 '19 at 23:30

3 Answers3

5
('sys.argv', ['/Volumes/128GB/tests/testweb/manage.py', 'runserver', '7000'])

Connected to pydev debugger (build 192.6817.19)

pydev debugger: process 19300 is connecting

('setup', {'multiproc': True, 'save-asyncio': False, 'vm_type': None, 'save-threading': False, 'save-signatures': False, 'multiprocess': False, 'module': False, 'server': False, 'client': '127.0.0.1', 'file': '/Volumes/128GB/tests/testweb/manage.py', 'DEBUG_RECORD_SOCKET_READS': False, 'cmd-line': False, 'print-in-debugger-startup': False, 'qt-support': '', 'port': 52573})



('sys.argv', ['/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python', '/Applications/PyCharm CE.app/Contents/helpers/pydev/pydevd.py', '--port', '52573', '--client', '127.0.0.1', '--multiproc', '--file', '/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python', '/Volumes/128GB/tests/testweb/manage.py', 'runserver', '7000'])

pydev debugger: process 19301 is connecting

('setup', {'multiproc': True, 'save-asyncio': False, 'vm_type': None, 'save-threading': False, 'save-signatures': False, 'multiprocess': False, 'module': False, 'server': False, 'client': '127.0.0.1', 'file': '/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python', 'DEBUG_RECORD_SOCKET_READS': False, 'cmd-line': False, 'print-in-debugger-startup': False, 'qt-support': '', 'port': 52573})

  • OS: macOS 10.15.1 (19B88)
  • Python: 2.7.16
  • PyCharm: 2019.2.3 (Community Edition)

My issue too.

pydev should parse the exec python script file to the "--file" args. But when fork a child process, it add the python binary to "--file" args.
OMG, it kill lot of my time to handle this. But the root cause still not be found.

You can append

args = args[1:]

below

from _pydevd_bundle.pydevd_command_line_handling import setup_to_argv

in your pydev_monkey.py file inside PyCharm installed directory. this can temporally make Debug function fine.

e.g. /Applications/PyCharm CE.app/Contents/helpers/pydev/_pydev_bundle/pydev_monkey.py on my computer.

1

Try running with noreload, seems like it failed when the autoreloader which spawns a child process because pydev tries to interpret python executable as a script Screenshot

Chok Yip
  • 49
  • 1
0

Running with noreload can solve the problem “SyntaxError: Non-ASCII character '\xcf' in file”.There is another problem when I run in normal mode. enter image description here SyntaxError: Non-ASCII character '\xe6'

To define a source code encoding, a magic comment must be placed into the source files either as first or second line in the file(e.g. /Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_bundle/pydev_monkey.py), such as: "# --coding:utf-8 -- "