gpt4 book ai didi

python - 名称 '_C' 未定义 pytorch+jupyter 笔记本

转载 作者:行者123 更新时间:2023-12-02 09:19:44 24 4
gpt4 key购买 nike

我有一些使用 pytorch 的代码,可以在我的 IDE (pycharm) 中正常运行。

为了研究,我尝试从 jupyter 笔记本运行它。

笔记本中的代码:

from algorithms import Argparser
from algorithms import Session
def main():
print("main started")
args = Argparser.parse()
session = Session(args)
session.run()

包装如下:

|-algorithms
|---__init__.py
|---Argparser.py
|---Session.py
|---<many more files that are being used by Session>.py

其中一些文件导入torch

当在笔记本中运行代码时,我得到

NameError Traceback (most recent call last) in 1 from algorithms import Argparser ----> 2 from algorithms import Session 3 def main(): 4 print("main started") 5 args = Argparser.parse()

D:\git\stav\stav-rl\algorithms\Session.py in 12 13 ---> 14 from algorithms.Episode import Episode 15 from algorithms.Agent import Agent 16 import torch

D:\git\stav\stav-rl\algorithms\Episode.py in 1 author = 'Noam' 2 ----> 3 import torch 4 import numpy as np 5 import cv2

c:\anaconda3\envs\threadartrl\lib\site-packages\torch__init__.py in 84 from torch._C import * 85 ---> 86 all += [name for name in dir(C) 87 if name[0] != '' and 88 not name.endswith('Base')]

NameError: name '_C' is not defined

错误出现在 from Algorithms import Session-->...-->import torch

如何让代码运行?

最佳答案

重新启动内核即可解决问题。

关于python - 名称 '_C' 未定义 pytorch+jupyter 笔记本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54408973/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com