开发者

Cannot import django.core

I am trying to setup django with fastcgi on apache. Django is installed and seems to be running correctly but I am having problems with setting up fastcgi.

I decided to test out my dispatch.开发者_高级运维fcgi script in the interactive python shell line by line and the following line:

from django.core.servers.fastcgi import runfastcgi

results in the following error:

ImportError: No module named core.servers.fastcgi

I can import django with no problem but import django.core gives yet another ImportError (No module named core).

How can I go about ensuring that I can import django.core. If I can import django then in must be on my path, and so why can I not import core?


You probably have a file/folder called django somewhere in your path, that isn't the actual path.

try this

import sys
sys.path

And then check everything in that output to see if there is a file/folder called django(.py) somewhere.

If so, change the path (sys.path = ['/path/to/directory/below/django/install'] + sys.path) or move/rename the file.


Probably you have django.py module in your working directory or in any other that is in python path.


For anyone having this problem and coming across this question like I did, it turns out that fastcgi support has been removed as of Django 1.9, thus you will get this import error if trying to import it. Refer Using Django with virtualenv, get error ImportError: No module named 'django.core.servers.fastcgi'

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜