Python ModuleNotFoundError:没有名为';xxx和x27;
Pycharm导入工作正常,但在终端中执行test_settings.py时,出现以下错误:Python ModuleNotFoundError:没有名为';xxx和x27;,python,flask,import,module,path,Python,Flask,Import,Module,Path,Pycharm导入工作正常,但在终端中执行test_settings.py时,出现以下错误: 导入测试模块“/home/ed/pycharm项目/TTime/tests/test_settings.py”时导入错误 提示:确保您的测试模块/包具有有效的Python名称 回溯: 测试/测试设置。py:3:in 从ttime导入应用程序,数据库 E ModuleNotFoundError:没有名为“ttime”的模块 这是我的Flask项目结构。我试图在主文件夹和测试文件夹中包含init.py,但没
导入测试模块“/home/ed/pycharm项目/TTime/tests/test_settings.py”时导入错误 提示:确保您的测试模块/包具有有效的Python名称 回溯: 测试/测试设置。py:3:in 从ttime导入应用程序,数据库 E ModuleNotFoundError:没有名为“ttime”的模块 这是我的Flask项目结构。我试图在主文件夹和测试文件夹中包含init.py,但没有任何变化。python路径似乎有问题
.
├── config.py
├── README.md
├── requirements.txt
├── runserver.py
├── tests
│ ├── functional
│ │ └── __init__.py
│ ├── pytest.ini
│ ├── test_settings.py
│ └── unit
│ ├── __init__.py
│ └── test_models.py
└── ttime
├── __init__.py
├── models.py
├── routes.py
├── static
└── templates
├── base.html
└── index.html
你确定这不仅仅是一个打字错误吗?检查test_settings.py中的导入。您正在从ttime导入名为
ttime
的模块。models import User,Timesheet/home/ed/PycharmProjects/ttime/TTIMEMEMEAYBE您可以使用..ttime.models import User、Timesheet或from…ttime.models import User来修复它,时间表
不确定我得到了以下信息:回溯:测试/测试设置。py:5:in from..ttime.models导入用户,时间表E导入错误:尝试在没有已知父包的情况下进行相对导入