Forums

Scheduled work with import error

I want to send push notifications to my users hourly.

from push_notifications.models import APNSDevice 
print('test schedule task') device = APNSDevice.objects.all() 
if device is None:
    print('None Device') print('number of models is '+str(len(device))) device.send_message('test')

Above is what I try to execute hourly.

But when executed that script, what i got is an error message :

Traceback (most recent call last): 
File "/home/User/Folder/Project/App/schedule.py", line 1, in 
from push_notifications.models import APNSDevice ImportError: No module named push_notifications.models

2016-03-19 05:49:05 -- Completed task, took 0.00 seconds, return code was 1."

What should I do to solve this one?

print(sys.path)) is below :

['/home/User/Folder/Project/App', '/usr/local/lib/python2.7/dist-packages/snappy-2.3.2-py2.7-linux-x86_64.egg', '/usr/local/lib/python2.7/dist-packages/cypari-1.2.2-py2.7-linux-x86_64.egg', '/usr/local/lib/python2.7/dist-packages/pypng-0.0.18-py2.7.egg', '/usr/local/lib/python2.7/dist-packages/FXrays-1.3.1-py2.7-linux-x86_64.egg', '/usr/local/lib/python2.7/dist-packages/spherogram-1.4.1-py2.7-linux-x86_64.egg', '/usr/local/lib/python2.7/dist-packages/plink-1.8-py2.7.egg', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/local/lib/python2.7/dist-packages/Orange/orng', '/usr/local/lib/python2.7/dist-packages/PIL', '/usr/lib/python2.7/dist-packages', '/usr/lib/pymodules/python2.7', '/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode']

What am I missing now?

[edit by admin: formatting]

Without knowing more about the directory structure of your project, it's hard to say, but if the directory push_notifications is in the directory /home/User/Folder/Project then you should have that on your path.

If it's actually at /home/User/Folder/Project/App, then it's more perplexing -- perhaps I could look at your files? (We can see them from our side, but we always ask permission first.)