事实:在Windows PC上安装了Django,尝试在本地测试应用程序,并在尝试运行测试HTTP服务器后吐出这个错误:" ImportError at /"
其他事实: 异常位置:第8行的C:\ Python27 \ tutorial \ snippets \ views.py
相关代码(来自上述异常位置的views.py,第1-10行):
from django.http import HttpResponse
from django.views.decorators.csrf import csrf_exempt
from rest_framework.renderers import JSONRenderer
from rest_framework.parsers import JSONParser
from rest_framework.response import Response
from snippets.models import Snippet, User, Credit_Card, Driver, Pending_Ride, User_Ride
from snippets.serializers import SnippetSerializer, UserSerializer, CreditCardSerializer, DriverSerializer, PendingRideSerializer, UserRideSerializer
import requests
import json
from datetime import datetime
from django.utils import timezone
回溯:
Traceback:
File "C:\Python27\lib\site-packages\django\core\handlers\base.py" in get_response
119. resolver_match = resolver.resolve(request.path_info)
File "C:\Python27\lib\site-packages\django\core\urlresolvers.py" in resolve
366. for pattern in self.url_patterns:
File "C:\Python27\lib\site-packages\django\core\urlresolvers.py" in url_patterns
402. patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "C:\Python27\lib\site-packages\django\core\urlresolvers.py" in urlconf_module
396. self._urlconf_module = import_module(self.urlconf_name)
File "C:\Python27\lib\importlib\__init__.py" in import_module
37. __import__(name)
File "C:\Python27\tutorial\tutorial\urls.py" in <module>
10. url(r'^', include('snippets.urls')),
File "C:\Python27\lib\site-packages\django\conf\urls\__init__.py" in include
33. urlconf_module = import_module(urlconf_module)
File "C:\Python27\lib\importlib\__init__.py" in import_module
37. __import__(name)
File "C:\Python27\tutorial\snippets\urls.py" in <module>
2. from snippets import views
File "C:\Python27\tutorial\snippets\views.py" in <module>
8. import requests
Exception Type: ImportError at /
Exception Value: No module named requests
应用程序具有我尝试运行的结构: https://github.com/david-zhou/uberserver
其他: 我按照本指南安装了服务器: http://www.toptal.com/django/installing-django-on-iis-a-step-by-step-tutorial
在上述过程中,我没有遇到任何麻烦。服务器正在Windows 8 PC上运行。在cd&#39到文件夹之后,我通过运行以下命令来部署应用程序: &#34; python manage.py runserver&#34;
如果你们中的任何人需要任何其他信息,请告诉我。
答案 0 :(得分:0)
您在本地系统上没有包。只需安装包'请求'即可。
尝试转到C:\ path \ to \ python和pip.exe install requests
。
如果您尚未安装pip,请查看此https://pypi.python.org/pypi/pip