I can run a script fine without docker, but when I have to use docker I run it and I get an import error: no module named c.H.
In my docker container, I can do:
python
import c.H
Everything works fine. But the second I try to run script.py, I get the import error that there is no module named c.H
I do not get this error when I don't use docker.
it's possible that the python version you are using inside the container is different from the python version the script is using. And different version of python may have different packages installed. You could check the python version the script is using from the shebang line. The shebang line should look something like the following:
#!/usr/bin/env python
You are trying to import a module from a package. See this answer to learn the difference between a module and a package. Your problem may be that your package isn't recognized as a package due to a missing __ init.py__ file. Add an empty one to the c directory if you don't already have one.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With