Cannot load submodule
See original GitHub issueI have a project with structure below:
- /
|- src
|- main.py
|- __init__.py
|- submodule
|- __init__.py
|- ...
|- web
|- web.py
|- __init__.py
|- Dockerfile
main.py calls entry function defined in web.py, and web.py calls functions defined in submodule. It works fine with command line python main.py. Then I plan to deploy it under docker, with Dockerfile:
FROM tiangolo/uwsgi-nginx-flask:python3.6
COPY ./src/* /app/
Build and run, I got error:
Traceback (most recent call last):
File "./main.py", line 1, in <module>
from web import run
File "./web.py", line 5, in <module>
import submodule
ModuleNotFoundError: No module named 'submodule'
Why did uwsgi cannot find submodule? Did I miss something?
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
GIT submodule could not be loaded - Visual Studio Feedback
The issue with the .git file still using the relative path is that the submodule project does not recognize it is under source...
Read more >Cannot open git submodule folder on GitHub online
I cannot open the root folder of the repo in my project repo here. I looked at this answer and it says that...
Read more >Cannot open directory because it is a submodule' #93 - GitHub
Hi, I'm having an issue with Git submodules as described below: Description When a directory is a GIT submodule, an attempt to open...
Read more >Git - Submodules - Git SCM
Although DbConnector is a subdirectory in your working directory, Git sees it as a submodule and doesn't track its contents when you're not...
Read more >Using Git submodules with GitLab CI/CD
Use Git submodules to keep a Git repository as a subdirectory of another Git repository. You can clone another repository into your project...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Thanks @tiangolo and @frankjdelgado, it finally works.
Thanks @frankjdelgado for the help!
So, @YTed , your problem inspired me to add more specific documentation for those cases.
I just created a new release with an example project using a Python package structure (like you). You can download the example project here.
I also updated the README docs on how to use the
flask runcommands, that would be the equivalent ofpython main.pybut will work even if you have a package structure.…and as an extra, I’m creating a pull request to your project, so you can see exactly what I changed to make it work. 🎉
Let me know if you still have problems after that, or otherwise, you can close this issue.