由于从 Ubuntu 14.04 升级到 16.04,我在本地开发服务器上收到以下错误:

ERROR    2016-06-19 14:03:10,294 wsgi.py:263]
Traceback (most recent call last):
File "/home/mort/google_appengine/google/appengine/runtime/wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/home/mort/google_appengine/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "/home/mort/google_appengine/google/appengine/runtime/wsgi.py", line 85, in LoadObject
obj = __import__(path[0])
File "/home/mort/python/ms-image-analysis/src/index.py", line 5, in <module>
import imagemodels
File "/home/mort/python/ms-image-analysis/src/imagemodels.py", line 5, in <module>
import numpy.random as random
File     "/home/mort/google_appengine/google/appengine/tools/devappserver2/python/sandbox.py", line 705, in load_module
module = self._find_and_load_module(fullname, fullname, [module_path])
File "/home/mort/google_appengine/google/appengine/tools/devappserver2/python/s andbox.py", line 446, in _find_and_load_module
return imp.load_module(fullname, source_file, path_name, description)
File "/usr/lib/python2.7/dist-packages/numpy/__init__.py", line 180,  in <module>
from . import add_newdocs
File "/usr/lib/python2.7/dist-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/usr/lib/python2.7/dist-packages/numpy/lib/__init__.py", line 8, in <module>
from .type_check import *
File "/usr/lib/python2.7/dist-packages/numpy/lib/type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "/usr/lib/python2.7/dist-packages/numpy/core/__init__.py", line 22, in <module>
from . import _internal  # for freeze programs
File "/usr/lib/python2.7/dist-packages/numpy/core/_internal.py", line 14, in <module>
import ctypes
File "/usr/lib/python2.7/ctypes/__init__.py", line 10, in <module>
from _ctypes import Union, Structure, Array
File "/home/mort/google_appengine/google/appengine/tools/devappserver2/python/sandbox.py", line 963, in load_module
raise ImportError('No module named %s' % fullname)
ImportError: No module named _ctypes

它似乎是由 numpy 导入触发的。我的本地 numpy 版本是 1:1.11.0。我应该使用运行时支持的 1.6.1 版吗?

谢谢,

莫特

最佳答案

在执行以下操作时,您需要在本地系统上安装相应版本的 1.6.1 以匹配运行时支持的版本 1.6.1:

libraries:
- name: numpy
  version: "1.6.1"

尽管使用 app engine flexible ,您可以运行您想要的任何版本的 numpy ;)

关于python - 无法在 google-app-engine 开发服务器上导入 ctypes,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/37908391/

10-15 22:55