0

Here is the thing:

When you developing a project, and test the code, you don't want to copy the code to sys.path, I mean python site-packages.So you have to use relative import.

the structure is:

|- pymonitoringplusin

    |- ftp_ftplib.py

|- tests

    |- test_ftp.py

I want to import source code from develop path, not python site-packages.

Here is the code in test_ftp.py:

from ..pymonitoringplugins.ftp_ftplib.py import Ftp

But got error:

ValueError: Attempted relative import in non-package

Here is the source code:

https://github.com/crazy-canux/pymonitoringplugins

Canux
  • 31
  • 7
  • Sorry, the code is : from ..pymonitoringplugins.ftp_ftplib import Ftp – Canux May 24 '17 at 05:07
  • it is not working as package, refer to this https://stackoverflow.com/questions/11536764/how-to-fix-attempted-relative-import-in-non-package-even-with-init-py – Tiny.D May 24 '17 at 05:49

0 Answers0