Python 3 ModuleNotFoundError我已经尝试了所有解决方案

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

我尝试了所有解决方案,包括设置导出路径等,但是都失败了。不确定我在做什么错。

我正在从命令行python sub/tests/branch1/demo/test_script.py执行文件

在test_script中,它是从sub / sriptclass / demosripts / desc.py导入文件

但是,我不断收到找不到模块的错误。以前可以使用,但是更新我的电脑后,一切都搞砸了。

python python-3.x pycharm
1个回答
0
投票

运行时

python sub/tests/branch1/demo/test_script.py

搜索导入的基本路径实际上是从sub / tests / branch1 / demo]开始>

然后在脚本执行时执行

 import sub.sriptclass.demosripts.desc.py

它将找到文件sub / tests / branch1 / demo / sub / sriptclass / demosripts / desc.py

->>找不到

在项目文件夹包括中创建test.py文件

import sub.tests.branch1.demo.test_script

了解它

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