Skip to content Skip to sidebar Skip to footer

Dev_appserver.py App.yaml Produces: ImportError: Importing The Multiarray Numpy Extension Module Failed

I run this command: dev_appserver.py app.yaml and I get an error: Traceback (most recent call last): File 'C:\Users\sehrlich\AppData\Local\Google\Cloud SDK\google-cloud-sdk\pla

Solution 1:

As Dan Cornilescu said, GAE Standard can't use libraries with code compiled in 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 is one of those cases, you can see it in their Git Repo [3] and in Wikipedia [4] (Written in: Python, C). Also, check the first answer to this SO question.

Curiously enough, I found a version on NumPy only based on "pure" Python called "TinyNumPy" [5] that you could use in GAE Standard. This are its limitations according to their 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.

In a nutshell, either you use GAE Flex or try to avoid NumPy.


Solution 2:

Since you want to use the GAE-supplied numpy then:

  • you shouldn't have it installed inside your application code (the traceback indicates it's running from the app's lib dir, where vendored-in libraries go)
  • you should request it in your app.yaml's libraries section:

    libraries:
    - name: numpy
      version: "1.6.1"
    
  • you should also have the requested numpy version installed locally on your system (but not in the app dir) so that the development server can use it as numpy is one of the libraries with such requirement, see Using built-in bundled libraries with the local development server:

Many of the built-in libraries provided by the runtime are automatically available to the local development server. However, the following built-in libraries must be installed locally before you can use them with the local development server:

...


Post a Comment for "Dev_appserver.py App.yaml Produces: ImportError: Importing The Multiarray Numpy Extension Module Failed"