执行python脚本时报错Error processing line 1 of xxxxxx\distutils-precedence.pth
原创
©著作权归作者所有:来自51CTO博客作者Liujun_Deng的原创作品,请联系作者获取转载授权,否则将追究法律责任
问题描述:执行python脚本时报错Error processing line 1 of xxxxxx\distutils-precedence.pth,如下所示:
系统:Microsoft Windows 10 企业版
Python版本:Python 3.11.5
1、问题重现
C:\Users\Administrator\PycharmProjects\pythonProject\venv\Scripts\python.exe D:\Python_Scripts\main.py
Error processing line 1 of C:\Users\Administrator\PycharmProjects\pythonProject\venv\Lib\site-packages\distutils-precedence.pth:
Traceback (most recent call last):
File "<frozen site>", line 186, in addpackage
File "<string>", line 1, in <module>
SyntaxError: source code string cannot contain null bytes
Remainder of file ignored
Error processing line 1 of C:\Users\Administrator\PycharmProjects\pythonProject\venv\Lib\site-packages\distutils-precedence.pth:
Traceback (most recent call last):
File "<frozen site>", line 186, in addpackage
File "<string>", line 1, in <module>
SyntaxError: source code string cannot contain null bytes
Remainder of file ignored
1275
Process finished with exit code 0
2、异常原因
此为服务器环境配置不对导致.
3、解决方案
打开C:\Users\Administrator\PycharmProjects\pythonProject\venv\Lib\site-packages\distutils-precedence.pth文件, 将import os;后面添加enter换行即可,如下所示:
4、验证
如下所示,修改后python脚本执行时不在报错.