无法在 Google App Engine 开发服务器上导入 ctypes

4

自从将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吗?

谢谢,

Mort

1个回答

4
你需要在本地安装与运行时支持版本1.6.1相匹配的1.6.1对应版本来执行以下操作:
libraries:
- name: numpy
  version: "1.6.1"

虽然使用灵活的应用引擎,您可以运行任何您想要的版本的numpy ;)


谢谢,我明白了。App Engine Flexible(也称为Managed VMs)不断更改外部库的规则:vm_settings中的apt-get,然后是Dockerfile,现在是requirements.txt。我已经很厌倦跟进这些变化了。此外,没有免费的配额 :-) - MortCanty
哈哈,确实是免费配额。 希望一旦从测试版转为正式版,事情就会稳定 :) - Jeffrey Godwyll

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接