google-code-export / django-syncr

Automatically exported from code.google.com/p/django-syncr
0 stars 0 forks source link

cron sync does not import modules correctly #46

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
*What steps will reproduce the problem?

0. everything works fine in the admin panel (I use twitter and delicious)
1. my PYTHONPATH is
'/home/pp/django/apps:/home/pp/django/src:/home/pp/django/projects'
2. my project is '/home/pp/django/projects/pp'
3. my sync script is as follows

#!/home/pp/opt/local/bin/python

import sys
import os

sys.path += ['/home/pp/django/src']
sys.path += ['/home/pp/django/projects']
sys.path += ['/home/pp/django/apps']

os.environ['DJANGO_SETTINGS_MODULE'] = 'pp.settings'

import settings
from syncr.app.tweet import TwitterSyncr
# other code

* What is the expected output?
no output

* What do you see instead?
Traceback (most recent call last):
  File "cron/syncr.py", line 14, in <module>
    from syncr.app.tweet import TwitterSyncr
  File "/home/pp/cron/syncr.py", line 14, in <module>
    from syncr.app.tweet import TwitterSyncr
ImportError: No module named app.tweet

* What version of the product are you using?
trunk

* On what operating system?
debian linux, python 2.6.1, django trunk

Original issue reported on code.google.com by federico.maggi on 8 Mar 2009 at 3:49

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Here is a more detailed test.

[04:04:10]<pp@host:/home/pp/> cat cron/syncr.py
#!/usr/bin/env python
import os
import sys
sys.path += ['/home/pp/django/src']
sys.path += ['/home/pp/django/projects']
sys.path += ['/home/pp/django/apps']
os.environ['DJANGO_SETTINGS_MODULE'] = 'pp.settings'

from pp import setting
sfrom syncr.app.tweet import TwitterSyncr
t = TwitterSyncr('user', 'pass')
t.syncTwitterUserTweets('user')

[04:04:15]<pp@host:/home/pp/> cron/syncr.py
Traceback (most recent call last):
  File "cron/syncr.py", line 11, in <module>
    from syncr.app.tweet import TwitterSyncr
  File "/home/pp/cron/syncr.py", line 11, in <module>
    from syncr.app.tweet import TwitterSyncr
ImportError: No module named app.tweet

[04:04:19]<pp@host:/home/pp/> /usr/bin/env pythonPython 2.6.1 (r261:67515, Mar  
7
2009, 00:47:26) 
[GCC 3.3.5 (Debian 1:3.3.5-13)] on linux2Type "help", "copyright", "credits" or
"license" for more information.
>>> import os, sys
>>> sys.path += ['/home/pp/django/src']
>>> sys.path += ['/home/pp/django/projects']
>>> sys.path += ['/home/pp/django/apps']
>>> os.environ['DJANGO_SETTINGS_MODULE'] = 'pp.settings'
>>> from pp import settings
>>> from syncr.app.tweet import TwitterSyncr
/home/opt/local/lib/python2.6/site-packages/twitter.py:25: DeprecationWarning: 
the
md5 module is deprecated; use hashlib instead
  import md5
>>> t = TwitterSyncr('user', 'pass')
>>> t.syncTwitterUserTweets('user')
>>> 

Original comment by federico.maggi on 8 Mar 2009 at 4:13

GoogleCodeExporter commented 9 years ago
This is a clear PYTHONPATH issue. Now you are setting the PYTHONPATH using 
sys.path which is good. But 
where exactly is syncr.

I think its in pp. So you should be adding

Anyway you are having a directory 'pp' which is inside of another 'pp' which is 
confusing. Make sure you put 
__init__.py in the directory which contains syncr and also set the python path 
and give it a try...

Original comment by yash...@gmail.com on 9 Mar 2009 at 7:16

GoogleCodeExporter commented 9 years ago
I think it probably is an environment variable issue too. Where do you have the 
syncr app installed to? 
Underneath /home/pp/django/apps ? Are you on Dreamhost ?

Original comment by jesse.l...@gmail.com on 11 Mar 2009 at 12:22

GoogleCodeExporter commented 9 years ago
This may be a dumb question, but what is the name of your sync script? I just 
spent
20 minutes with a sync script names 'syncr.py' until I realized that Python was
looking for 'app.tweet' inside it.

Original comment by kchar...@gmail.com on 24 Feb 2010 at 6:17