I've added the Redistogo add-on on Heroku,but I can't to test it out in the console mode. I have done this in accordance with the documentation.
$ heroku run python --app redis-to-go
Running python attached to terminal... up, run.1
Python 2.7.2 (default, Oct 31 2011, 16:22:04)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> f=open('requirements.txt', 'w')
>>> f.write('redis==2.4.12'+'\n' )
>>> f.close()
>>>
>>> f=open('store.py', 'w')
>>> f.write('import os'+'\n' )
>>> f.write('import urlparse'+'\n' )
>>> f.write('import redis'+'\n' )
>>> f.write("url = urlparse.urlparse(os.environ.get('REDISTOGO_URL', 'redis://localhost'))"+'\n' )
>>> f.write('redis = redis.Redis(host=url.hostname, port=url.port, db=0, password=url.password)'+'\n' )
>>> f.close()
>>>
>>> from store import redis
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "store.py", line 3, in <module>
import redis
ImportError: No module named redis
The Heroku's Python finds:os,urlparse but can't find redis.
Is there anyone who help me? I need only the Heroku's Python console mode!
With the local Python and remote REDISTOGO I don't have any problem!
Update:
From the documentation:
Deploying to Heroku
To use Redis To Go on Heroku, install the redistogo add-on:
$ heroku addons:add redistogo
Test that it works from the Heroku console:
$ heroku run python
Python 2.7.2 (default, Oct 31 2011, 16:22:04)
>>> from store import redis
>>> redis.set('answer', 42)
True
>>> redis.get('answer')
'42'
It doesn't work from the Heroku console!
Please share your practice on this.
Why you guys try to make all with the remote console?? Do the app locally (create store.py, requirements.txt) and then deploy it!! Heroku sees the requirements.txt when you deploy (or push) your app and it adds the necessary libraries. So that's why it didn't work, because redis library is not installed on your heroku dyno.
I'm not a python developer but I've done this without problems
https://github.com/ismaelga/python-redis-heroku