简体   繁体   English

未找到模块 python(在 IDE 外运行)

[英]No Module Found python (run outside IDE)

I'm trying to run a script outside pycharm and this is what happens my command prompt when i try to run the main.py我正在尝试在 pycharm 之外运行脚本,这就是我尝试运行 main.py 时的命令提示符

C:\Users\Beatriz\PycharmProjects\Tese\Main> python main.py
Traceback (most recent call last):
File "main.py", line 1, in <module>
from View.view import *
ModuleNotFoundError: No module named 'View'

C:\Users\Beatriz\PycharmProjects\Tese\Main>

I put each file in a package like this: files_packaging我将每个文件放在 package 中,如下所示: files_packaging

Still it seems not recognize the module "View"似乎仍然无法识别模块“视图”

my main code:我的主要代码:

from View.view import *

if __name__ == "__main__":
    View()

The best way is to move the contents of the Main folder outside of it, directly inside the Test folder where all the other folders are.最好的方法是将Main文件夹的内容移到它之外,直接在所有其他文件夹所在的Test文件夹中。 That way you can directly invoke from View.view import * .这样您就可以直接from View.view import *调用。

To run the script:要运行脚本:

cd PycharmProjects/Tese
python main.py

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM