首页 > 解决方案 > 在项目中找不到模块(Python)

问题描述

我是初学者,我不了解项目文件夹结构中的某些内容。

我有这个项目:

.
└── convertersProject/
    ├── conftest.py -----------------> best practice if you're not using src structure
    ├── converters  -----------------> module I'm trying to import/
    │   ├── __init__.py
    │   ├── binconverter.py
    │   └── importester1.py  --------> import binconverter OR from converters import */
    │       └── submodule/
    │           ├── __init__.py -----> not needed if I don't want to use it as package
    │           └── importester2.py -> from converter import binconverter 
    ├── outsidemodule  /
    │   ├── importester3.py
    │   └── __init__.py 
    └── test /
        └── test_converters.py

ModuleNotErrorFound尝试importester1/2/3.py直接从项目文件夹执行时,我总是收到。我正在使用虚拟环境,python -m venv 'name'从 pyenv python 3.8.5 设置pyenv shell 3.8.5

我想我理解的是:

我到底在想什么?

标签: pythonmodulepytest

解决方案


推荐阅读