attempted relative import with no known parent package,已解决

发现是第六行导数据的错误,

错误显示需要尝试在没有已知父包的情况下进行相对导入,那就说明需要修改路径,我的从deep_sort开始

运行

成功解决。

  • 3
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
This error message is raised when attempting to use a relative import in Python, but the parent package or module is not known or cannot be found. A relative import is a way to import a module or package relative to the current module, rather than using an absolute import that specifies the full path to the module. For example, if you have a package structure like this: ``` mypackage/ __init__.py module1.py subpackage/ __init__.py module2.py ``` You could use a relative import in `module2.py` to import `module1.py` like this: ```python from ..module1 import some_function ``` The `..` means to go up one level in the package hierarchy to find the parent package, which in this case is `mypackage`. If you get the error message "attempted relative import with no known parent package", it means that Python cannot find the parent package or module. This can happen if: - The module or package you're trying to import from does not have a parent package, or it is not structured correctly. - You are trying to run the module directly as the main script, rather than importing it as a module. Relative imports only work when the module is imported as part of a package. - You are using an older version of Python that does not support relative imports (they were introduced in Python 2.5). To fix this error, make sure that your package structure is correct and that you are importing modules correctly. If you are using an older version of Python, you may need to switch to using absolute imports instead.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值