简体   繁体   中英

heroku: issue importing python module

This is my project structure:

project_name
|___src
    |___model.py

On my local dev environment, I have added project_name 's parent directory to PYTHONPATH, so I can do from project_name.src.model import func_name in a file inside the project.

But when I push the project to heroku, it pushes the contents of project_name inside an app directory, hence my imports fail.

Is there any way to make this work on heroku?

I faced the same issue. The issue in my case was the module name in my case was clashing with a internal module of heroku/gunicorn.

A possible fix is to have this folder structure.

project_name
|___internal_package_name
    |___src
        |___model.py
        |...others
    |___domain
    |___others
|___wsgi.py

而是在wsgi.py中执行该路径操作。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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