Forums

Import Error: No Module Named

I have the package structure:

 `-- mysite/
         |-- __init__.py
         |--test.py
    `-- app/
         |-- __init__.py
          `-- start.py

In the start.py file I do

 from mysite.test import runit 
  runit()

I also tried

from mysite import test
test.runit()

I get No Module Named mysite

The sys.path:

/home/jahmul14/mysite/app
/usr/lib/python3.5
/usr/lib/python3.5/plat-x86_64-linux-gnu
/usr/lib/python3.5/lib-dynload
/usr/local/lib/python3.5/dist-packages
/usr/lib/python3/dist-packages
/home/jahmul14/mysite

Not sure what I am doing wrong.

You need the directory that contains the mysite directory to be on sys.path.

Ok, I set the sys.path to include /home/jahmul14 and it worked. How do you set the the PYTHONPATH of a virtualenv? Can I just change the activate script?

That would work if you are using the virtualenv from a bash console, but not from a web app. For a web app, just change it in the WSGI file (linked from the "Web" tab).