I have made a Python 3 script for testing a project of mine. The script has this structure:
main.py
myRequest.py
external/
requests/
__init__.py
many files of the library...
When I run python3 main.py
the file myRequest.py
is imported. Inside that file, I do import external.requests as reqs
.
This works for me, and also passes on Travis CI
However, when I put the above files in the folder test
of my project, the Travis CI job cannot find the module:
ImportError: No module named external.requests.
When I tried running the script in an online IDE (c9, Ubuntu 14.04, Python 3.4.0) it was able to import it.
At c9, I have tried doing from .external import requests as reqs
but it raises a :
SystemError: Parent module '' not loaded, cannot perform relative import.
Adding an empty __init__.py
file or running python3 -m main.py
did nothing.
What should I do so that the import is successful at Travis CI?