2

This is the structure of my files:

D:\projects
  -projects\bin
    -bin\__init__.py
    -bin\app.py

  -projects\test
    -test\app_test.py

  -projects\__init__.py

I want to use app.py in my app_test files, and I write:

from bin.app import app

But it seems this doesn't work.

How can I organize my files and import my own modules?

Toby Speight
  • 27,591
  • 48
  • 66
  • 103
Jutta
  • 513
  • 5
  • 13

1 Answers1

1

You will have to create a:

__init__.py 

file in the root directory. This link will explain more of why you need it, and the contents of such file.

Regards,

Community
  • 1
  • 1
Juan Chacon
  • 134
  • 6
  • I understand why I should write such files. But is it right in powershell: PS D:\projects> python tests/app_test.py – Jutta Mar 05 '16 at 02:09
  • If you want to solve it the easy way you can add the path `(..\\bin\\)` using `sys.path.append` and then importing the `app.py` module – Juan Chacon Mar 07 '16 at 11:01