我收到以下错误
"ModuleNotFoundError: No module named 'class1'"
结构
- hello-world
- src
- __init__
- main
- class1
- Procfile
The main1
文件看起来像这样:
from class1 import G
APP = Flask(__name__)
@APP.route('/', methods=['GET'])
def index() -> str:
return 'We are alive'
Profile:
web: gunicorn src.main:app --log-file -
heroku 日志向我们显示以下错误:
ModuleNotFoundError:没有名为“class1”的模块
我不知道我做错了什么。我在用pipenv
安装依赖项,它包含gunicorn
.
您必须使用以下方式导入该类:
from .class1 import G
不要忘记点。当你构建一个包时,你必须使用这个相对路径来告诉你的类是在哪里编写的。这称为包内引用。
参见对应的doc https://docs.python.org/3/tutorial/modules.html#intra-package-references.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)