8

Before start I have been trying to accomplish it for some time now, but I had no luck. I'm trying to create my own python package, which I will import the modules in it, in separate files in my project. I tried to add my project's directory to pythonpath via 'sys' but still the mod_wsgi do not recognize it:

import sys
sys.path.append('/var/www/')

from core.core import main

And when trying:

ImportError: No module named core.core

Any help would be appreciated

0xmtn
  • 2,625
  • 5
  • 27
  • 53

2 Answers2

6

If you do not have the file __init__.py in your core folder, it will not be recognized as a package.

Therefore the solution is to add a file __init__.py in your core folder.

If you have already added the problem may be the absolute path ... the core folder that has absolute path:

  1. /var/www/core
  2. /var/www/YourProject/core

if the second option you have to do: sys.path.append('/var/www/YourProject')

Artjom B.
  • 61,146
  • 24
  • 125
  • 222
wancharle
  • 106
  • 2
  • You have used single quote at the beginning of your last code line, and a double quote at the end of that line. – Zen Apr 29 '14 at 04:39
0

You need to explicitly set PYTHONPATH with you root directory.

abhishek kumar
  • 339
  • 3
  • 11