我运行这个命令:
dev_appserver.py app.yaml
我收到一个错误:
Traceback (most recent call last):
File "C:\Users\sehrlich\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\runtime\wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "C:\Users\sehrlich\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\runtime\wsgi.py", line 299, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "C:\Users\sehrlich\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\runtime\wsgi.py", line 85, in LoadObject
obj = __import__(path[0])
File "C:\Users\sehrlich\Desktop\ToolKit\Application Projects\Tableau Web Data Connector Improvement\tableauextensions\main.py", line 2, in <module>
from Get_Data import get_data, build_connection, run_sql
File "C:\Users\sehrlich\Desktop\ToolKit\Application Projects\Tableau Web Data Connector Improvement\tableauextensions\Get_Data.py", line 1, in <module>
import numpy as np
File "C:\Users\sehrlich\Desktop\ToolKit\Application Projects\Tableau Web Data Connector Improvement\tableauextensions\lib\numpy\__init__.py", line 142, in <module>
from . import add_newdocs
File "C:\Users\sehrlich\Desktop\ToolKit\Application Projects\Tableau Web Data Connector Improvement\tableauextensions\lib\numpy\add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "C:\Users\sehrlich\Desktop\ToolKit\Application Projects\Tableau Web Data Connector Improvement\tableauextensions\lib\numpy\lib\__init__.py", line 8, in <module>
from .type_check import *
File "C:\Users\sehrlich\Desktop\ToolKit\Application Projects\Tableau Web Data Connector Improvement\tableauextensions\lib\numpy\lib\type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "C:\Users\sehrlich\Desktop\ToolKit\Application Projects\Tableau Web Data Connector Improvement\tableauextensions\lib\numpy\core\__init__.py", line 26, in <module>
raise ImportError(msg)
ImportError:
Importing the multiarray numpy extension module failed. Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try `git clean -xdf` (removes all
files not under version control). Otherwise reinstall numpy.
我已经安装并卸载了 NumPy。当我运行类似的东西时,他们的应用程序工作正常
python -m flask run
并且它使用 NumPy 没有问题。无法弄清楚问题出在哪里。
最佳答案
正如 Dan Cornilescu 所说,GAE Standard 不能使用用 C 编译的代码的库 [1] [2] :
[From 1] You can use third-party libraries that are pure Python code with no C extensions
[From 2] The interpreter cannot load Python services with C code; it is a "pure" Python environment.
NumPy 就是其中之一,您可以在他们的 Git Repo [3] 中看到它。在维基百科中[4] (编写语言:Python、C)。另外,请检查此问题的第一个答案 SO question .
奇怪的是,我在 NumPy 上发现了一个仅基于“纯”Python 的版本,名为“TinyNumPy”[5]您可以在 GAE 标准中使用。根据 Git Repo,这是它的局限性:
- ndarray.flat iterator cannot be indexed (it is a generator).
- No support for Fortran order.
- Support for data types limited to bool, uin8, uint16, uint32, uint64, int8, int16, int32, int64, float32, float64.
- Functions that calculate statistics on the data are much slower, since the iteration takes place in Python.
- Assigning via slicing is usually pretty fast, but can be slow if the striding is unfortunate.
简而言之,要么使用 GAE Flex,要么尝试避免 NumPy。
关于python - dev_appserver.py app.yaml 生成 : ImportError: Importing the multiarray numpy extension module failed,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52503620/