Python 属性错误:模块';配置';没有属性';配置';
Untitled.ipynb和config.py位于同一文件夹中。 因此,我在Untitled.ipynb中调用config.py 但是,jupyter说'AttributeError:module'config'没有属性'config' 为什么? 请帮帮我( 无标题.ipynbPython 属性错误:模块';配置';没有属性';配置';,python,Python,Untitled.ipynb和config.py位于同一文件夹中。 因此,我在Untitled.ipynb中调用config.py 但是,jupyter说'AttributeError:module'config'没有属性'config' 为什么? 请帮帮我( 无标题.ipynb import config import numpy as np print(config) con = config.Config() #Input training files from benchmarks/FB
import config
import numpy as np
print(config)
con = config.Config()
#Input training files from benchmarks/FB15K/ folder.
....
config.py
#coding:utf-8
import torch
import torch.nn as nn
import numpy as np
from torch.autograd import Variable
import torch.optim as optim
import os
import time
import datetime
import ctypes
import json
class Config(object):
r"""In this class, we set the configuration parameters, adopt C library for data and memory processing. In the following,
we train models and test models.
"""
def __init__(self):
self.lib = ctypes.cdll.LoadLibrary("./release/Base.so")
self.lib.sampling.argtypes = [ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p, ctypes.c_int64, ctypes.c_int64, ctypes.c_int64]
self.lib.getHeadBatch.argtypes = [ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p]
self.lib.getTailBatch.argtypes = [ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p]
self.lib.testHead.argtypes = [ctypes.c_void_p]
self.lib.testTail.argtypes = [ctypes.c_void_p]
self.test_flag = False
self.in_path = "./"
self.out_path = "./"
self.bern = 0
self.hidden_size = 100
....
如果尚未将请求库升级到至少>=1.2版本。如果尚未升级,请将请求库升级到至少>=1.2版本。是否确实没有导入名为
config
的Python包而不是本地模块?例如,我解决了它。Probelm是config.py中的奇怪标记。谢谢你的评论!你确定你没有导入名为config
的Python包而不是本地模块吗?例如,我解决了它。Probelm是config.py中的奇怪标记。谢谢你的评论!