赞
踩
Apple M2 Max
Mac OS 13.2.1
Pycharm 2022.3.2
Python 2.7.18
因为开发的项目比较老,从Windows平台迁移后Mac后一直出现无法debug的问题,run模式正常,具体报错如下:
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
搜了很多博客,说的方法基本是在文件头加上utf8的标识,实际上并没有用,stack overflow上有效的解答,在此记录一下。
参开链接:https://stackoverflow.com/questions/58634837/pycharm-returns-non-asciii-error-on-running-in-django-server-in-debug-mode-work
解决方法:
/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_bundle/pydev_monkey.py
from _pydevd_bundle.pydevd_command_line_handling import setup_to_argv
在这一行下添加一行
args = args[1:]
重新debug就可以正常工作
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。