-->

Using Django with virtualenv, get error ImportErro

2020-04-08 11:19发布

问题:

I'm using virtualenv and trying to host my django app. I'm using Python 3.5 and Django 1.9.2. I can run import django fine. When I run

from django.core.servers.fastcgi import runfastcgi

I get the error

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'django.core.servers.fastcgi'

My Path:

['', '/home/wrapupne/venv/lib/python35.zip', '/home/wrapupne/venv/lib/python3.5', '/home/wrapupne/venv/lib/python3.5/plat-linux', '/home/wrapupne/venv/lib/python3.5/lib-dynload', '/usr/local/lib/python3.5', '/usr/local/lib/python3.5/plat-linux', '/home/wrapupne/venv/lib/python3.5/site-packages']

Any ideas?

回答1:

FastCGI support was deprecated in 1.7, and the module you're trying to import was removed in 1.9. The only protocol supported by Django in 1.9 is WSGI.

If, for some reason, you cannot use WSGI directly, you need to use an adapter that can serve a WSGI application as FastCGI.



回答2:

I think this module was removed in Django 1.9

The documentation for this module in version 1.8 says that will be removed in 1.9: https://docs.djangoproject.com/en/1.8/howto/deployment/fastcgi/