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
ma
I encountered the same issue, so I am posting here in hope to help somebody:
The quick fix for me was to add this line export PYTHONPATH=$PYTHONPATH:$(pwd)
in the .travis.yml
:
before_install:
- "pip install -U pip"
- "export PYTHONPATH=$PYTHONPATH:$(pwd)"
Having a setup.py
which should be the default option as it is the most elegant.
With that you would resolve your relative import issue, try one configured like:
from setuptools import setup, find_packages
setup(name='MyPythonProject',
version='0.0.1',
description='What it does',
author='',
author_email='',
url='',
packages=find_packages(),
)
And then add this line in .travis.yml
before_install:
- "pip install -U pip"
- "python setup.py install