python - 如何在本地运行 OpenShift Django 项目?

标签 python django openshift

我正在尝试使用以下命令在本地运行我的 django 1.6 项目(从 openshift 下载): $python3.3 manage.py runserver

并得到错误:

Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0xb691592c>
Traceback (most recent call last):
  File "/usr/local/lib/python3.3/dist-packages/Django-1.6-py3.3.egg/django/utils/module_loading.py", line 21, in import_by_path
    module = import_module(module_path)
  File "/usr/lib/python3.3/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1584, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1565, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1529, in _find_and_load_unlocked
ImportError: No module named 'wsgi'

During handling of the above exception, another exception occurred:

............................................................
..........................................................
...................................................
  File "<frozen importlib._bootstrap>", line 1584, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1565, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1529, in _find_and_load_unlocked
django.core.exceptions.ImproperlyConfigured: WSGI application 'wsgi.application' could not be loaded; Error importing module wsgi: "No module named 'wsgi'"

但在 openshift.com 上它可以工作。如何在本地运行它以进行快速调试?

最佳答案

这个问题有点晚了,但我遇到了同样的问题,并提出了替代解决方案。

我添加

sys.path.append(os.path.join(os.path.dirname(__file__), '..', ".."))

openshift/manage.py 内部

mysite/wsgi.py 中的其他内容

else:
    from django.core.wsgi import get_wsgi_application
    application = get_wsgi_application()

关于python - 如何在本地运行 OpenShift Django 项目?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22874808/

相关文章:

python - cv2.imshow显示二进制图像

javascript - 如何使用ajax抓取页面?

java - 如何在 Tomcat/openshift 上执行包含 main() 的 java 类

django - Django 的模型验证器中可以使用多个值吗?

python - openshift不会加载aiml文件

node.js - 无法让 Node 应用程序在 openshift 上运行,错误 : listen EACCES

javascript - tensorflow 和 keras 在同一模型和张量上的不同结果

python - 动态更改pyqt5中的数据破折号

python - np.sum 和 np.add.reduce 有什么区别?

Django : when client request http methods that are not defined in the view class