pycharm debugger 错误 lost sys.stdout /Connection to Python debugger failed Socket closed

本文记录了一次使用Python进行调试时遇到的错误:连接到Python调试器失败及标准流初始化问题,并给出了具体的错误信息与堆栈跟踪。通过查阅Stack Overflow找到了解决办法,即避免使用可能引起调试器混乱的模块名。
部署运行你感兴趣的模型镜像

错误描述

Connection to Python debugger failed Socket closed

Fatal Python error: Py_Initialize: can't initialize sys standard streams
Traceback (most recent call last):
  File "/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/io.py", line 52, in <module>
  File "/Users/lihao/Desktop/code/TCP/day2 shiyan/abc.py", line 1, in <module>
RuntimeError: lost sys.stdout

解决方案

在 stackoverflower 找到解决方案: https://stackoverflow.com/questions/45122480/pycharm-runtimeerror-lost-sys-stdout-how-to-fix-this

abc.py 是io调用的一个模块,debugger时不能识别到底是哪一个模块,所以以后对于这些模块文件起名字应该注意一下。

您可能感兴趣的与本文相关的镜像

Python3.8

Python3.8

Conda
Python

Python 是一种高级、解释型、通用的编程语言,以其简洁易读的语法而闻名,适用于广泛的应用,包括Web开发、数据分析、人工智能和自动化脚本

with open(fr'{outpath}\AMR_GetInitialLots_HE.txt', 'r', encoding='utf-8') as file: list = [] for ind,i in enumerate(file): # print(i) # extract title if ind <= 6 : if ind == 2: temp = i.replace("'", "").split(' ') title = temp[2:-1] title.append(temp[-1][:-1]) print(title) else: continue else: if len(i) <= 1: break else: res = i.split("' '") ls = [] for ind,item in enumerate(res): try: if ind == 0: # 'Lotid ls.append(item[1:]) elif ind == len(res)-1: # CurrentLocationFlag'/n ls.append(item[:-3]) else: ls.append(item) except: print(fr'Error lot info: {res}') # record_list.append([fr'Error lot info: {res}']) # pd.DataFrame(record_list).to_csv(fr'{outpath}\record_{start_time_str}.csv') # pd.DataFrame(record_list).to_csv(fr'{outpath}\record.csv') list.append(ls) list2 = pd.DataFrame(list).drop_duplicates() list2.columns = title list2.to_csv(fr'{outpath}\HE_scheduling_initial.csv', header=True, index=False) D:\#\python\PythonProject\venv\Scripts\python.exe "D:/#/python/PyCharm/PyCharm Community Edition 2023.1/plugins/python-ce/helpers/pydev/pydevd.py" --multiprocess --qt-support=auto --client 127.0.0.1 --port 49372 --file D:\#\python\HE\HE_scheduling.py Connected to pydev debugger (build 231.8109.197) Job Start: 2025-12-22 18:48:56.555703 Load pkl: 0:00:00.056000 \\B1apfrtd35\APFHOME\bin.win64\V9.4.0\status_tool -timeout 60 10.232.9.128 20066 dlis Station AAA Category AMR/DIFF Report AMR_WhatNext_Common_GetInitialLots_HE > D:\#\python\HE\AMR_GetInitialLots_HE.txt Load initial: 0:00:01.313004 Traceback (most recent call last): File "D:\#\python\PyCharm\PyCharm Community Edition 2023.1\plugins\python-ce\helpers\pydev\pydevd.py", line 1496, in _exec pydev_imports.execfile(file, globals, locals) # execute the script File "D:\#\python\PyCharm\PyCharm Community Edition 2023.1\plugins\python-ce\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile exec(compile(contents+"\n", file, 'exec'), glob, loc) File "D:\#\python\HE\HE_scheduling.py", line 542, in <module> list2.columns = title NameError: name 'title' is not defined. Did you mean: 'file'? python-BaseException 为什么会报错且执行完这个AMR_GetInitialLots_HE这个文件会被清空,且AMR_GetInitialLots_HE这个文件一定大于三行
最新发布
12-23
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值