1

I'm running Python3 in App Engine (Fleixble) and am receiving the following error:

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.

I uploaded the numpy library "pip3 install -t /lib numpy" and have it in my requirements file (not sure if this is correct).

Requirements.txt:

Flask==1.0.2
gunicorn==19.7.1
numpy==1.15.4

I've re-installed numpy a few times and receive this log:

Collecting numpy
Using cached
https://files.pythonhosted.org/packages/74/68/2b00ba3c7390354db2a1706291750b6b7e911f6f79c0bd2184ae04f3c6fd/numpy-1.15.4-cp36-cp36m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
quandl 3.2.0 has requirement requests<2.18,>=2.7.0, but you'll have 
requests 2.19.1 which is incompatible.
Installing collected packages: numpy
Successfully installed numpy-1.15.4

Any help would be greatly appreciated :)

EDIT:

I've come across this - https://github.com/numpy/numpy/issues/9272

However it appears this seems to affect Python 3.6.0 whereas the Python runtime interpreter is 3.6.4 (as specified by '3') in the app.yaml file. More information about Google's Python configuration here - https://cloud.google.com/appengine/docs/flexible/python/runtime

Dustin Ingram
  • 20,502
  • 7
  • 59
  • 82
Hews
  • 569
  • 6
  • 19

1 Answers1

1

The issue is that you're installing the built distribution ("wheel") for macOS, but the environment that you're attempting to use the dependency in is not macOS. You can tell this based on the filename:

numpy-1.15.4-cp36-cp36m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl

You'll want to explicitly specify the platform/ABI/implementation options to those which the Flex environment requires:

$ pip install \
    --target lib \
    --python-version 36 \
    --platform manylinux1_x86_64 \
    --abi cp36m \
    --implementation cp \
    --only-binary=:all:
    numpy

Make sure to do this from a clean lib directory, and with the latest version of pip.

Dustin Ingram
  • 20,502
  • 7
  • 59
  • 82
  • Okay thanks! Now I'm receiving this error - ImportError: C extension: No module named 'pandas._libs.tslib' not built. If you want to import pandas from the source directory, you may need to run 'python setup.py build_ext --inplace --force' to build the C extensions first. How can I build the C extensions first? – Hews Dec 11 '18 at 02:29