Heroku Python does not find redis (redistogo) to import

I added the Redistogo add-on to Heroku, but I can’t test it in console mode. I did this according to 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

Heroku Python finds: os, urlparse, but cannot find redis.
Is there anyone who helps me? I only need the console mode of Heroku Python!
With local Python and remote REDISTOGO, I have no problem!

Update:

From the documentation:

Heroka Deployment

To use Redis To Go on Heroku, install the redistogo add-on:

$ heroku addons:add redistogo

Verify 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'

This does not work from the Heroku console!

Share your practice with this.

+3
source share
2

, git, . :

heroku run python --app redis-to-go

. . , virtualenv, :

pip install redis

. , . redis .txt, dyno.

, :

cat "redis==2.4.12" >> requirements.txt
git add requirements.txt
git commit -m 'adding redis'
git push heroku master
heroku addons:add redis-to-go
heroku run python --app redis-to-go

intrepreter python:

import os
import urlparse

import redis

url = urlparse.urlparse(os.environ.get('REDISTOGO_URL', 'redis://localhost'))

redis = redis.Redis(host=url.hostname, port=url.port, db=0, password=url.password)
redis.set('answer', 42)
redis.get('answer')
+3

, , ? ( store.py, requirements.txt), ! Heroku .txt ( ) . , , redis ​​ dynku heroku.

python,

https://github.com/ismaelga/python-redis-heroku

0

All Articles