Python3 module import fails on Travis ci

I made a Python 3 script to test my project. The script has the following structure:

main.py
myRequest.py
external/
  requests/
    __init__.py
    many files of the library...

At startup, the python3 main.pyfile is imported myRequest.py. Inside this file I am doing import external.requests as reqs. This works for me and also passes Travis CI

However, when I put the above files into test my project folder , the Travis CI job cannot find the module :

ImportError: No module named external.requests.

When I tried to run the script in the online IDE (c9, Ubuntu 14.04 , Python 3.4.0 ), it was able to import it. In c9, I tried to do from .external import requests as reqs, but it calls a:

SystemError: Parent module '' not loaded, cannot perform relative import.

Adding an empty file __init__.pyor starting python3 -m main.pydid nothing.

, Travis CI?

+4
1

, -:

, PYTHONPATH=$PYTHONPATH:$(pwd) .travis.yml:

before_install:
  - "pip install -U pip"
  - "export PYTHONPATH=$PYTHONPATH:$(pwd)"

setup.py

setup.py, , . , :

from setuptools import setup, find_packages

setup(name='MyPythonProject',
      version='0.0.1',
      description='What it does',
      author='',
      author_email='',
      url='',
      packages=find_packages(),
     )

.travis.yml

before_install:
  - "pip install -U pip"
  - "python setup.py install
0

All Articles