So I have a path structure that looks like this:
~/Dropbox/Coding/Python/Chessbotslack/scripts/Flask_interface.py
~/Dropbox/Coding/Python/Chessbotslack/database/spreadsheets.py
The first line of the Flask_interface.py is:
from Chessbotslack.database.spreadsheets import add_game
If I run this from my IDE (PyCharm) it runs just fine; but if I run it from my terminal it throws the error:
Traceback (most recent call last):
File "Flask_interface.py", line 1, in <module>
from Chessbotslack.database.spreadsheets import add_game
ModuleNotFoundError: No module named 'Chessbotslack'
To solve this I did two things:
1) Adding __init__.py to the directories
This did seem to accomplish anything
2) Adding the directory to $PYTHONPATH
In terminal I ran
export PYTHONPATH=$PYTHONPATH:~/Dropbox/Coding/Python
This solved the problem for running it from my terminal, but as expected it did not solve it for my IBM-Cloud. Perhaps it has something to do with the requirements.txt file?
2018-04-16T09:08:45.30+0200 [APP/PROC/WEB/0]ERR File "scripts/Flask_interface.py", line 1, in <module>
2018-04-16T09:08:45.30+0200 [APP/PROC/WEB/0]ERR from Chessbotslack.database.spreadsheets import add_game
2018-04-16T09:08:45.30+0200 [APP/PROC/WEB/0]ERR ImportError: No module named Chessbotslack.database.spreadsheets