1

I have a directory structure like:

.
└── app
    ├── urlregister.py
    ├── __init__.py
└── resource
    └── report
          ├── main.py
          ├── __init__.py

I need to import urlregister in file main.py . Please help me and give me any code.

Regards,

Sovankiry
  • 135
  • 1
  • 14
  • Do you use Apache with mod_wsgi? – Alexander R. Mar 27 '15 at 05:15
  • Did you take a look at http://stackoverflow.com/questions/28527832/absolute-vs-relative-imports-in-python-2/28963444#28963444 ? I guess, it's a possible duplicate. – pnv Mar 27 '15 at 05:39

1 Answers1

2

You need to use sys.path for this. Python by default, searches for the current directory for the files to be imported.

You can do something like this

import sys;
sys.path.insert(0, '/path/to/application/app(folder)')

import urlregister
samgak
  • 23,944
  • 4
  • 60
  • 82
Arpit Goyal
  • 2,212
  • 11
  • 31