I have a python/django application that runs on the google app engine.
My views.py file has some imports…
from commands.userCommands import RegisterUserCommand
from commands.accountCommands import CreateNewAccountCommand, RenameAccountCommand
These imports work fine on my development environment (local machine). But when I upload to the google app engine, views.py fails with a “Could not import views. Error was: No module named userCommands” error.
Any idea why I can’t import my commands.userCommands module?
My file structure looks as follows…
- app.yaml
- urls.py
- views.py
- etc...
- commands/__init__.py
- commands/userCommands.py
Note: I did try to append my application name to the module name/path. No luck.
Note: I did do an update with the –noisy argument, and it does appear to upload my commands folder successfully.
You could be running into a clash with Python’s own
commandsmodule (which doesn’t have submodules like yours) — naming your own modules and packages in ways that are meant to hide ones in the standard library (just like naming your variables in ways that are meant to hide builtin names, likelistorfile) is always a perilous undertaking, even though it “should” work there’s always potential for confusion.Could you try renaming that
commandspackage and its uses to something unambiguous and free from danger, such asmycommands, and see if that just makes the problem disappear? If that’s the case you can then open a ticket on GAE’s tracker (because it would show a minor but undeniable bug in GAE’s runtime) but meanwhile your problem is solved!-) If the problem stays, ah well, at least we’ve eliminated one likely cause and can keep digging…