python-3.x - “ModuleNotFoundError: No module named”但给出了正确的路径
问题描述
经典错误,尽我所能。
我想workers-python/workers/composite_key/compositekey/tests/test.py
从workers-python-framework/workers_manager/pwmf/pipeline/utils.py
.
错误发生在test.py
:
from workers-python-framework.workers_manager.pwmf.pipeline.utils import local_mode
utils.py
“本地模式”:
local_mode = ModeDefinition(
name='local',
resource_defs={
's3': s3_resource,
'tempfile': tempfile_resource,
'file_cache': fs_file_cache,
'file_manager': local_file_manager,
'mds_store': mds_store,
'fqdn_string': fqdn_string,
},
executor_defs=default_executors + [dask_executor],
system_storage_defs=s3_plus_default_storage_defs,
)
但是,正确的路径和拼写存在...
me@PF2DCSXD:/mnt/c/Users/user/Documents/GitHub/workers-python-framework/workers_manager/pwmf/pipeline$ ls
utils.py
是什么导致了这个错误?我该如何解决?
终端:
me@PF2DCSXD:/mnt/c/Users/user/Documents/GitHub/workers-python/workers/composite_key/compositekey/tests$ pytest -s test_composite_key.py
========================================================================================== test session starts ==========================================================================================platform linux -- Python 3.8.10, pytest-6.2.5, py-1.10.0, pluggy-1.0.0
rootdir: /mnt/c/Users/user/Documents/GitHub/workers-python/workers/composite_key/compositekey, configfile: pytest.ini
collected 0 items / 1 error
================================================================================================ ERRORS =================================================================================================_____________________________________________________________________________ ERROR collecting tests/test_composite_key.py ______________________________________________________________________________ImportError while importing test module '/mnt/c/Users/user/Documents/GitHub/workers-python/workers/composite_key/compositekey/tests/test_composite_key.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/usr/lib/python3.8/importlib/__init__.py:127: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
test_composite_key.py:11: in <module>
from pwmf.pipeline.utils import local_mode
E ModuleNotFoundError: No module named 'pwmf'
======================================================================================== short test summary info ========================================================================================ERROR test_composite_key.py
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!=========================================================================================== 1 error in 1.20s ============================================================================================
pwmf
是一个单独的克隆 git 项目,我在项目的配置文件中引用了它。
poetry.lock
:
[[package]]
name = "pwmf"
version = "0.1.2.15"
description = "Python Worker Management Framework."
category = "main"
optional = false
python-versions = ">=3.7,<4.0"
pyproject.toml
:
pwmf = "^0.1.2.4"
如果还有什么我可以添加到帖子中,请告诉我。
解决方案
推荐阅读
- android - 从 Uri 检索位图有时为空
- javascript - 脚本在乘法中包含单位
- rust - 如何在不消耗迭代器 int rust 的情况下获取元素(在 rust 中重写 strtol 的问题)
- python - 删除字符串列表中每个项目中的重复项
- python - ImageDataGenerator 拟合模型时的形状问题
- sql - SQL 从标志中获取 2 个相邻的操作
- regex - 如果 url 包含 fbclid 参数并删除它,如何通过 htaccess 重定向到 https
- reactjs - React Navigation,如何测试 Navlink 的路径?
- excel - Selenium Webdriver - 等到用户单击没有 ID 的按钮
- c# - 如何投射 Func
功能