question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot load submodule

See original GitHub issue

I 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:closed
  • Created 6 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
YTedcommented, Sep 4, 2017

Thanks @tiangolo and @frankjdelgado, it finally works.

1reaction
tiangolocommented, Sep 2, 2017

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 run commands, that would be the equivalent of python main.py but 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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found