我在Heroku中添加了Redistogo插件,但我無法在控制檯模式下對其進行測試。 我已經按照documentation這樣做過。Heroku的Python沒有找到用於導入的redis(redistogo)
$ 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的發現:操作系統,但裏urlparse找不到Redis的。
有誰幫我?我只需要Heroku的Python控制檯模式!
與本地Python和遠程REDISTOGO我沒有任何問題!
更新:
從文檔:
部署到Heroku的
要使用Redis的去的Heroku,安裝redistogo附加:
$ heroku addons:add redistogo
從Heroku控制檯測試它的工作原理:
$ 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'
從Heroku控制檯不起作用!
請分享你的這方面的做法。
我需要它用於調試和因爲文檔的! –