qq_41824788 2025-03-05 10:39 采纳率: 0%
浏览 20

AttributeError: module 'builtins' has no attribute 'interpreter'

import time
import uuid
import argparse
import datetime

from model import *
from utils import *

import sys
import os
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'sparse_tools_master')))

#from ..sparse_tools-master.sparse_tools.utils import SparseAdjList
from sparse_tools_master.sparse_tools.utils import SparseAdjList

def main(args):
    #print(builtins.interpreter)

    # 返回异构图,邻接表,初始标签,类别数,数据加载器,训练集节点id,测试集节点id
    g, adjs, init_labels, num_classes, dl, trainval_nid, test_nid = load_dataset(args)

debug深度学习程序时,在pycharm的console窗口查看变量,就会报错:
AttributeError: module 'builtins' has no attribute 'interpreter'
【之前是可以正常使用的,这两天不知道弄了点啥,就不能用了】

猜测:和conda环境的库有关,但不知道怎么解决

我的环境:

img

  • 写回答

4条回答 默认 最新

  • 阿里嘎多学长 2025-03-05 10:39
    关注

    阿里嘎多学长整理AIGC生成,因移动端显示问题导致当前答案未能完全显示,请使用PC端查看更加详细的解答过程

    解决方案

    PyCharm 的 Console 窗口中查看变量时,可能会出现 AttributeError: module 'builtins' has no attribute 'interpreter' 错误。这是因为 PyCharm 在 Console 窗口中默认使用的是 Python 的交互式解释器,而不是 Python 的解释器的 __builtins__ 模块。

    解决方法是:

    1. 在 PyCharm 的 Console 窗口中,输入 import __builtins__ 并回车键,这样可以将 __builtins__ 模块导入到当前作用域中。
    2. 或者,在 PyCharm 的 Settings 中(File -> Settings -> Tools -> Python Interpreter),将 Python 的解释器设置为 python,而不是 python -i

    这样,PyCharm 的 Console 窗口中就可以正确地查看变量了。

    评论

报告相同问题?

问题事件

  • 修改了问题 3月5日
  • 修改了问题 3月5日
  • 创建了问题 3月5日