Spid无法识别导入的文件更改

2024-09-30 04:39:38 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试编辑从Github获取的项目文件。 我有两个python文件。名为“Dataset”的文件是从第一个python文件导入的。当我在“Dataset”中将函数“data_load”的名称更改为“yukle”时,spider无法识别该函数,前面的代码也可以工作。 我怎样才能解决这个问题

我重新启动了内核。在我的首选项上启用了Umr。它不起作用

第一个_file.py:

import io

from surprise import KNNBaseline
from surprise import Dataset
from surprise import get_dataset_dir

data = Dataset.yukle('ml-100k')

Dataset.py:

''类数据集:


def __init__(self, reader):

    self.reader = reader

@classmethod
def yukle(cls, name='ml-100k', prompt=True):

    try:
        dataset = BUILTIN_DATASETS[name]
    except KeyError:
        raise ValueError('unknown dataset ' + name +
                         '. Accepted values are ' +
                         ', '.join(BUILTIN_DATASETS.keys()) + '.')
    if not os.path.isfile(dataset.path):
        answered = not prompt
        while not answered:
            print('Dataset ' + name + ' could not be found. Do you want '
                  'to download it? [Y/n] ', end='')
            choice = input().lower()

            if choice in ['yes', 'y', '', 'omg this is so nice of you!!']:
                answered = True
            elif choice in ['no', 'n', 'hell no why would i want that?!']:
                answered = True
                print("Ok then, I'm out!")
                sys.exit()

        download_builtin_dataset(name)

    reader = Reader(**dataset.reader_params)

    return cls.load_from_file(file_path=dataset.path, reader=reader)

AttributeError: type object 'Dataset' has no attribute 'yukle'

Tags: 文件pathnamefromimporttruenotdataset

热门问题