user2924142
user2924142

Reputation: 15

Google App Engine Python2.7 local development fails to initialize ctypes dependent libraries

Googles local development server for the App Engine (dev_appserver.py) has stopped working for one of my long running projects. The project itself can and has been deployed without issue but throws an error while initializing modules (numpy and PIL) that call ctypes in local development. The error received can be seen below:

    import numpy as np
  File "/Users/dev/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/python/runtime/sandbox.py", line 894, in load_module
    module = self._find_and_load_module(fullname, fullname, [module_path])
  File "/Users/dev/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/python/runtime/sandbox.py", line 605, in _find_and_load_module
    return imp.load_module(fullname, source_file, path_name, description)
  File "/opt/miniconda3/envs/app-api/lib/python2.7/site-packages/numpy/__init__.py", line 142, in <module>
    from . import core
  File "/opt/miniconda3/envs/app-api/lib/python2.7/site-packages/numpy/core/__init__.py", line 95, in <module>
    from . import numeric
  File "/opt/miniconda3/envs/app-api/lib/python2.7/site-packages/numpy/core/numeric.py", line 39, in <module>
    from ._internal import TooHardError, AxisError
  File "/opt/miniconda3/envs/app-api/lib/python2.7/site-packages/numpy/core/_internal.py", line 17, in <module>
    import ctypes
  File "/opt/miniconda3/envs/app-api/lib/python2.7/ctypes/__init__.py", line 29, in <module>
    if int(_os.uname()[2].split('.')[0]) < 8:
ValueError: invalid literal for int() with base 10: ''

I also came across this question that has encountered similar issues as of late. Which make me feel it has to do with a recent change in the development server.

I have already tried to update the two packages to the latest 2.7 version as well as downgrading them to the GAE supported versions (numpy==1.6.1 and PIL==1.1.7). Also, removing the modules from the app.yaml file as mentioned in the other question seems to make no difference. The app.yaml file as used for deployment looks like so:

libraries:
- name: PIL
  version: "1.1.7"

- name: numpy
  version: "1.6.1"

Is anybody aware of changes with regard the development server for working with these libraries?

Upvotes: 0

Views: 155

Answers (1)

Jan Hernandez
Jan Hernandez

Reputation: 4640

This is a know issue that only affects to non linux OS

you can try the following workarounds

-- Downgrade your Cloud SDK to v260, this version is working fine on OSX, to do this please run this command

gcloud components update --version 260.0.0

-- Or edit the file google/appengine/tools/devappserver2/python/runtime/sandbox.py

In order to remove/comment this package '_ctypes' from the array _WHITE_LIST_C_MODULES as is stated in this Google public case

Upvotes: 1

Related Questions