0
我想在Openshift中設置一個Python 2.7項目。目標是使用Tornado Websockets。我已經嘗試了一些例子,但我一直陷在一個數字,在實例中所示缺失的環境變量。OpenShift中缺少環境變量
我目前app.py:
import imp
import os
try:
zvirtenv = os.path.join(os.environ['OPENSHIFT_PYTHON_DIR'],
'virtenv', 'bin', 'activate_this.py')
execfile(zvirtenv, dict(__file__ = zvirtenv))
except IOError:
pass
if __name__ == '__main__':
ip = os.environ['OPENSHIFT_PYTHON_IP']
port = int(os.environ['OPENSHIFT_PYTHON_PORT'])
app = imp.load_source('application', 'main.py')
app.application.listen(port , ip)
app.ioloop.IOLoop.instance().start()
我的安裝要求:
install_requires=['tornado', 'requests', 'beautifulsoup4']
這將導致以下錯誤:
---> Running application from Python script (app.py) ...
Traceback (most recent call last):
File "app.py", line 14, in <module>
zvirtenv = os.path.join(os.environ['OPENSHIFT_PYTHON_DIR'],
File "/opt/app-root/lib64/python2.7/UserDict.py", line 40, in __getitem__
raise KeyError(key)
KeyError: 'OPENSHIFT_PYTHON_DIR'
任何人可以幫助我嗎?
非常感謝您,它做到了 –