首页 > 解决方案 > Python: Cannot import from custom module

问题描述

I am having an issue with python not being able to find or import my module. I am unsure how to fix this problem. My py file I'm trying to get my import into is in 'main' folder, the file I'm trying to import is one level up. My program is a package:

Error I'm getting

models.py

标签: pythonhtml

解决方案


尝试将您的 .py 文件复制到Python 文件夹中的site-packages文件夹,然后从命令提示符 ( python -m <your_file_name>.py)/python 启动器/IDE 运行您的 python 文件。如果您仍然遇到错误,请分享您的代码,以便人们可以看到。


推荐阅读