Jackie2370 2023-03-01 11:20 采纳率: 100%
浏览 564
已结题

吴恩达C1_W1_Lab03_Model_Representation_Soln运行报错,无法解决

运行吴恩达老师C1_W1_Lab03_Model_Representation_Soln报错,按照几个解决方法我已经把deeplearning.mplstyle文件拷贝到个人安装的目录anaconda3\Lib\site-packages\matplotlib\style下,以及个人jupyter notebook工作目录下,但还是不行,总是提示TypeError: the 'package' argument is required to perform a relative import for './deeplearning'。请大佬给看看

img

  • 写回答

2条回答 默认 最新

  • m0_74089179 2023-03-05 17:51
    关注

    把路径的./去掉就可以了

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论 编辑记录
  • Jackie2370 2023-03-02 10:23
    关注
    TypeError                                 Traceback (most recent call last)
    Cell In[4], line 3
          1 import numpy as np
          2 import matplotlib.pyplot as plt
    ----> 3 plt.style.use('./deeplearning.mplstyle')
    
    File ~\anaconda3\lib\site-packages\matplotlib\style\core.py:153, in use(style)
        151 pkg, _, name = style.rpartition(".")
        152 try:
    --> 153     path = (importlib_resources.files(pkg)
        154             / f"{name}.{STYLE_EXTENSION}")
        155     style = _rc_params_in_file(path)
        156 except (ModuleNotFoundError, IOError) as exc:
        157     # There is an ambiguity whether a dotted name refers to a
        158     # package.style_name or to a dotted file path.  Currently,
       (...)
        161     # either use Path objects or be prepended with "./" and use
        162     # the slash as marker for file paths.
    
    File ~\anaconda3\lib\site-packages\importlib_resources\_common.py:46, in package_to_anchor.<locals>.wrapper(anchor, package)
         44 elif anchor is undefined:
         45     return func()
    ---> 46 return func(anchor)
    
    File ~\anaconda3\lib\site-packages\importlib_resources\_common.py:56, in files(anchor)
         51 @package_to_anchor
         52 def files(anchor: Optional[Anchor] = None) -> Traversable:
         53     """
         54     Get a Traversable resource for an anchor.
         55     """
    ---> 56     return from_package(resolve(anchor))
    
    File ~\anaconda3\lib\functools.py:888, in singledispatch.<locals>.wrapper(*args, **kw)
        884 if not args:
        885     raise TypeError(f'{funcname} requires at least '
        886                     '1 positional argument')
    --> 888 return dispatch(args[0].__class__)(*args, **kw)
    
    File ~\anaconda3\lib\site-packages\importlib_resources\_common.py:82, in _(cand)
         80 @resolve.register
         81 def _(cand: str) -> types.ModuleType:
    ---> 82     return importlib.import_module(cand)
    
    File ~\anaconda3\lib\importlib\__init__.py:122, in import_module(name, package)
        119 if not package:
        120     msg = ("the 'package' argument is required to perform a relative "
        121            "import for {!r}")
    --> 122     raise TypeError(msg.format(name))
        123 for character in name:
        124     if character != '.':
    
    TypeError: the 'package' argument is required to perform a relative import for './deeplearning'
    
    
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 3月15日
  • 已采纳回答 3月7日
  • 创建了问题 3月1日

悬赏问题

  • ¥15 Java环境配了,但启用不成功。
  • ¥15 求一个智能家居控制的代码
  • ¥15 ad软件 pcb布线pcb规则约束编辑器where the object matpcb布线pcb规则约束编辑器where the object matchs怎么没有+15v只有no net
  • ¥15 虚拟机vmnet8 nat模式可以ping通主机,主机也能ping通虚拟机,但是vmnet8一直未识别怎么解决,其次诊断结果就是默认网关不可用
  • ¥20 求各位能用我能理解的话回答超级简单的一些问题
  • ¥15 yolov5双目识别输出坐标代码报错
  • ¥15 这个代码有什么语法错误
  • ¥15 给予STM32按键中断与串口通信
  • ¥15 使用QT实现can通信
  • ¥15 关于sp验证的一些东西,求告知如何解决,