暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

执行python脚本时报错Error processing line 1 of xxxxxx\distutils-precedence.pth

Leo 2024-08-30
258

问题描述:执行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脚本执行时不在报错.


「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论