【问题标题】:Cartridge Python2.7 on OPenshiftOPenshift上的墨盒Python2.7
【发布时间】:2023-03-20 02:20:02
【问题描述】:

我尝试在主机 Openshift 上安装 Django 1.5。我使用墨盒 Python 2.7。我读了https://developers.openshift.com/en/python-getting-started.html。我不明白这段代码应该在哪里。

virtenv = os.environ['OPENSHIFT_PYTHON_DIR'] + '/virtenv/'
virtualenv = os.path.join(virtenv, 'bin/activate_this.py')
try:
  # See: http://stackoverflow.com/questions/23418735/using-python-3-3-in-openshifts-book-example?noredirect=1#comment35908657_23418735
  #execfile(virtualenv, dict(__file__=virtualenv)) # for Python v2.7
  #exec(compile(open(virtualenv, 'rb').read(), virtualenv, 'exec'), dict(__file__=virtualenv)) # for Python v3.3
  # Multi-Line for Python v3.3:
  exec_namespace = dict(__file__=virtualenv)
  with open(virtualenv, 'rb') as exec_file:
  file_contents = exec_file.read()
  compiled_code = compile(file_contents, virtualenv, 'exec')
  exec(compiled_code, exec_namespace)
except IOError:
pass 

此代码应在文件wsgi.py 中?上诉,给我在盒式 python Openshift 上的示例工作应用程序。

【问题讨论】:

    标签: python django openshift


    【解决方案1】:

    是的,这段代码应该放在 wsgi.py 文件中。

    举个例子(虽然这个例子使用的是 3.3 版本,但它会为您指明正确的方向),请查看提供的答案下的 cmets:Using Python 3.3 in OpenShift's book example

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多