问题
Very specific stuff. I'm running a Bitnami Django stack cloud VM on Amazon. On two different "regular" machines, I could install requests
by running sudo pip install requests
, but it seems that Bitname uses it's own specific structure, and something is going wrong when installing requests
that way. It can also be related to issue #2028, but it was fixed long time ago.
I have the following traceback:
Environment:
Request Method: GET
Request URL: http://54.94.226.137/
Django Version: 1.7.7
Python Version: 2.7.6
Installed Applications:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'vz_base',
'vz_api',
'vz_admin',
'vz_user')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware')
Traceback:
File "/opt/bitnami/python/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
98. resolver_match = resolver.resolve(request.path_info)
File "/opt/bitnami/python/lib/python2.7/site-packages/django/core/urlresolvers.py" in resolve
343. for pattern in self.url_patterns:
File "/opt/bitnami/python/lib/python2.7/site-packages/django/core/urlresolvers.py" in url_patterns
372. patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/opt/bitnami/python/lib/python2.7/site-packages/django/core/urlresolvers.py" in urlconf_module
366. self._urlconf_module = import_module(self.urlconf_name)
File "/opt/bitnami/python/lib/python2.7/importlib/__init__.py" in import_module
37. __import__(name)
File "/opt/bitnami/apps/django/django_projects/ProjetoVigZul/ProjetoVigZul/urls.py" in <module>
5. from vz_api import urls as api_urls
File "/opt/bitnami/apps/django/django_projects/ProjetoVigZul/vz_api/urls.py" in <module>
8. from vz_api import views
File "/opt/bitnami/apps/django/django_projects/ProjetoVigZul/vz_api/views.py" in <module>
14. from vz_api.dguard import DGuardManager, DGuardIntegrationException
File "/opt/bitnami/apps/django/django_projects/ProjetoVigZul/vz_api/dguard.py" in <module>
5. import requests, json
File "/opt/bitnami/python/lib/python2.7/site-packages/requests/__init__.py" in <module>
58. from . import utils
File "/opt/bitnami/python/lib/python2.7/site-packages/requests/utils.py" in <module>
25. from . import certs
Exception Type: ImportError at /
Exception Value: cannot import name certs
Website is live at http://54.94.226.137/, if anyone is interested.
回答1:
sudo pip install --upgrade requests
solved that for me
来源:https://stackoverflow.com/questions/29390360/bitnami-django-stack-and-module-requests-cannot-import-name-certs