0

我对 Django nonrel 的开发服务器有一个奇怪的问题:

我已经安装了Amazon Simple Product API,它在 shell 中运行良好,我可以在那里导入它,其他一切似乎都运行良好。但是当我尝试将其导入我的网站时,我得到了这个:

ImportError at /
No module named amazon.apiRequest Method:   GET
Request URL:    http://127.0.0.1:8000/
Django Version: 1.3
Exception Type: ImportError
Exception Value:    No module named amazon.api
Exception Location: /Users/Paulius/Desktop/Django-nonrel/projects/sort/phone/functions.py in <module>, line 3
Python Executable:  /opt/local/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
Python Version: 2.7.2
Python Path:    ['/Users/Paulius/Desktop/Django-nonrel/projects/sort',
 '/Users/Paulius/Desktop/Django-nonrel/projects/sort/djangoappengine/lib',
 '/usr/local/google_appengine',
 '/usr/local/google_appengine/lib/antlr3',
 '/usr/local/google_appengine/lib/enum',
 '/usr/local/google_appengine/lib/fancy_urllib',
 '/usr/local/google_appengine/lib/graphy',
 '/usr/local/google_appengine/lib/grizzled',
 '/usr/local/google_appengine/lib/httplib2',
 '/usr/local/google_appengine/lib/ipaddr',
 '/usr/local/google_appengine/lib/jinja2',
 '/usr/local/google_appengine/lib/markupsafe',
 '/usr/local/google_appengine/lib/oauth2',
 '/usr/local/google_appengine/lib/prettytable',
 '/usr/local/google_appengine/lib/protorpc',
 '/usr/local/google_appengine/lib/simplejson',
 '/usr/local/google_appengine/lib/sqlcmd',
 '/usr/local/google_appengine/lib/webapp2',
 '/usr/local/google_appengine/lib/webob',
 '/usr/local/google_appengine/lib/yaml/lib',
 '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django_cms-2.2-py2.7.egg',
 '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django_sekizai-0.5-py2.7.egg',
 '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django_mptt-0.5.2-py2.7.egg',
 '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/html5lib-0.95-py2.7.egg',
 '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/South-0.7.4-py2.7.egg',
 '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django_classy_tags-0.3.4.1-py2.7.egg',
 '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django_floppyforms-0.4.7-py2.7.egg',
 '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pygeoip-0.2.3-py2.7.egg',
 '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/six-1.1.0-py2.7.egg',
 '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/distribute-0.6.27-py2.7.egg',
 '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/bottlenose-0.4.0-py2.7.egg',
 '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/python_amazon_simple_product_api-1.1.0-py2.7.egg',
 '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip',
 '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
 '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
 '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
 '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
 '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
 '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old',
 '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload',
 '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages',
 '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PIL']
Server time:    Tue, 17 Jul 2012 18:11:04 +0000

我使用相同的 python 版本来运行服务器和 shell,我不知道出了什么问题。

追溯:

Environment:


Request Method: GET
Request URL: http://127.0.0.1:8000/

Django Version: 1.3
Python Version: 2.7.2
Installed Applications:
['django.contrib.contenttypes',
 'django.contrib.auth',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.admin',
 'phone',
 'django.contrib.admindocs',
 'djangotoolbox',
 'autoload',
 'dbindexer',
 'djangoappengine']
Installed Middleware:
('autoload.middleware.AutoloadMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware')


Traceback:
File "/Users/Paulius/Desktop/Django-nonrel/projects/sort/django/core/handlers/base.py" in get_response
  101.                             request.path_info)
File "/Users/Paulius/Desktop/Django-nonrel/projects/sort/django/core/urlresolvers.py" in resolve
  250.             for pattern in self.url_patterns:
File "/Users/Paulius/Desktop/Django-nonrel/projects/sort/django/core/urlresolvers.py" in _get_url_patterns
  279.         patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/Users/Paulius/Desktop/Django-nonrel/projects/sort/django/core/urlresolvers.py" in _get_urlconf_module
  274.             self._urlconf_module = import_module(self.urlconf_name)
File "/Users/Paulius/Desktop/Django-nonrel/projects/sort/django/utils/importlib.py" in import_module
  35.     __import__(name)
File "/usr/local/google_appengine/google/appengine/tools/dev_appserver_import_hook.py" in Decorate
  676.       return func(self, *args, **kwargs)
File "/usr/local/google_appengine/google/appengine/tools/dev_appserver_import_hook.py" in load_module
  1845.     return self.FindAndLoadModule(submodule, fullname, search_path)
File "/usr/local/google_appengine/google/appengine/tools/dev_appserver_import_hook.py" in Decorate
  676.       return func(self, *args, **kwargs)
File "/usr/local/google_appengine/google/appengine/tools/dev_appserver_import_hook.py" in FindAndLoadModule
  1717.                                          description)
File "/usr/local/google_appengine/google/appengine/tools/dev_appserver_import_hook.py" in Decorate
  676.       return func(self, *args, **kwargs)
File "/usr/local/google_appengine/google/appengine/tools/dev_appserver_import_hook.py" in LoadModuleRestricted
  1660.                                      description)
File "/Users/Paulius/Desktop/Django-nonrel/projects/sort/urls.py" in <module>
  2. from phone.views import *
File "/usr/local/google_appengine/google/appengine/tools/dev_appserver_import_hook.py" in Decorate
  676.       return func(self, *args, **kwargs)
File "/usr/local/google_appengine/google/appengine/tools/dev_appserver_import_hook.py" in load_module
  1845.     return self.FindAndLoadModule(submodule, fullname, search_path)
File "/usr/local/google_appengine/google/appengine/tools/dev_appserver_import_hook.py" in Decorate
  676.       return func(self, *args, **kwargs)
File "/usr/local/google_appengine/google/appengine/tools/dev_appserver_import_hook.py" in FindAndLoadModule
  1717.                                          description)
File "/usr/local/google_appengine/google/appengine/tools/dev_appserver_import_hook.py" in Decorate
  676.       return func(self, *args, **kwargs)
File "/usr/local/google_appengine/google/appengine/tools/dev_appserver_import_hook.py" in LoadModuleRestricted
  1660.                                      description)
File "/Users/Paulius/Desktop/Django-nonrel/projects/sort/phone/views.py" in <module>
  9. from functions import *
File "/usr/local/google_appengine/google/appengine/tools/dev_appserver_import_hook.py" in Decorate
  676.       return func(self, *args, **kwargs)
File "/usr/local/google_appengine/google/appengine/tools/dev_appserver_import_hook.py" in load_module
  1845.     return self.FindAndLoadModule(submodule, fullname, search_path)
File "/usr/local/google_appengine/google/appengine/tools/dev_appserver_import_hook.py" in Decorate
  676.       return func(self, *args, **kwargs)
File "/usr/local/google_appengine/google/appengine/tools/dev_appserver_import_hook.py" in FindAndLoadModule
  1717.                                          description)
File "/usr/local/google_appengine/google/appengine/tools/dev_appserver_import_hook.py" in Decorate
  676.       return func(self, *args, **kwargs)
File "/usr/local/google_appengine/google/appengine/tools/dev_appserver_import_hook.py" in LoadModuleRestricted
  1660.                                      description)
File "/Users/Paulius/Desktop/Django-nonrel/projects/sort/phone/functions.py" in <module>
  3. from amazon.api import AmazonAPI

Exception Type: ImportError at /
Exception Value: No module named amazon.api
4

1 回答 1

0

dev_appserever 会修改环境,因此您不会以在将项目部署到 App Engine 时不可用的方式包含库。

您必须将库放在您的实际项目文件夹中,或者至少从项目文件夹中软链接到它。

于 2012-07-17T19:47:21.647 回答