venv 中的 Python ModuleNotFoundError

问题描述 投票:0回答:1

我正在开发一个涉及车道检测的Python项目,我的项目结构如下图所示。

我正在尝试使用以下代码从

lanenet_model
中的
test_lanenet.py
导入模块:

蟒蛇

import sys
sys.path.append('C:/Users/SaiTeja/PycharmProjcts/NewGitCloneSDAI/Lanenet-lane-detection/lanenet_model')
from lanenet_model import lanenet

但是,我遇到了

ModuleNotFoundError:

回溯(最近一次调用最后一次): 文件“C:\Users\SaiTeja\PycharmProjects\NewGitCloneSDAI\lanenet-lane-detection ools est_lanenet.py”,第 23 行,位于 从 Lanenet_model 导入 Lanenet ModuleNotFoundError:没有名为“lanenet_model”的模块

vbnet

ModuleNotFoundError: No module named 'Lanenet_model'

File structure

我已确认

__init__.py
存在于
lanenet_model
目录中,使其成为一个包,并且我已检查我附加到
sys.path
的路径是否正确。

这是我迄今为止尝试过的:

  1. 确保
    sys.path.append()
    中的路径正确并指向
    lanenet_model
    上方的目录。
  2. 检查
    __init__.py
    是否存在于
    lanenet_model
    目录中。
  3. 从不同的目录运行脚本。

enter image description here

python import module pycharm modulenotfounderror
1个回答
0
投票

您好!

我需要有关 modulenotfound 错误的帮助。即使模块存在于路径文件中,它也会抛出如下错误。

如有任何帮助,我们将不胜感激。

谢谢, 恩迪尼

附上带有路径的错误屏幕截图

© www.soinside.com 2019 - 2024. All rights reserved.