Hey Juan,

It could be because in installing the C -based python modules locally, pip 
is compiling C code for your system's architecture, which wouldn't 
translate to the deployed machine. If this is the case, see if the 
following works as a solution:

You can write a Dockerfile for your Custom Runtime app that will install 
the requirements when the container image is built, that way it'll use the 
architecture of the container that will actually run the app. Here's an 
example Dockerfile from our python custom runtime github repository 
<https://github.com/GoogleCloudPlatform/python-runtime>:

FROM gcr.io/google-appengine/python

# Create a virtualenv for dependencies. This isolates these packages from
# system-level packages.
RUN virtualenv /env

# Setting these environment variables are the same as running
# source /env/bin/activate.
ENV VIRTUAL_ENV /env
ENV PATH /env/bin:$PATH

# Copy the application's requirements.txt and run pip to install all
# dependencies into the virtualenv.*ADD requirements.txt /app/requirements.txt
RUN pip install -r /app/requirements.txt*

# Add the application source code.
ADD . /app

# Run a WSGI server to serve the application. gunicorn must be declared as
# a dependency in requirements.txt.
CMD gunicorn -b :$PORT main:app

You can see the lines which install dependencies in bold.

Let me know how that works out for you! We could see about getting this 
caveat for custom runtime deployment and dependencies with c-based python 
modules documented if that turns out to be the case.

In order for me to be able to test and reproduce what you've seen in 
future, could you also attach the requirements.txt to your reply?

Cheers,

Nick
Cloud Platform Community Support

On Sunday, February 12, 2017 at 3:13:01 PM UTC-5, Juan Antonio Fernández 
Sánchez wrote:
>
> Thank you so much for the answer Nick, I'm trying to do this without 
> success. 
>
> I've the dependencie in my requirements.txt file and in the module where I 
> import the module like this: import pandas as pd-
>
> If I try to execute the code I've this exception:
>
> ImportError: Missing required dependencies ['numpy']
>
> And if I add numpy in requirements.txt (executing it) and add the module 
> in the same file where I've pandas I've this exception:
>
> 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' m searching solutions in Stack Overflow but I don't find anything 
> interesting. I don't know if you have some simple example where I could see 
> it working.
> I would like use only pandas but i don't know if in the future I will need 
> numpy.
>
> Could you help me?
>
> Thank you so mucho, any help will be welcome.
>
>
>
>
> El jueves, 9 de febrero de 2017, 20:07:42 (UTC+1), Nick (Cloud Platform 
> Support) escribió:
>>
>> Hey Juan Antonio, 
>>
>> As you noted correctly, in the Standard Environment 
>> <https://cloud.google.com/appengine/docs/about-the-standard-environment>, 
>> only pure python apps are supported. However in the Flexible Environment 
>> <https://cloud.google.com/appengine/docs/flexible/>, there is no such 
>> restriction, and you can run any python app, regardless of it's use of C 
>> libraries! All you'll need to do is go into your python app's app.yaml 
>> file and add the line "env: flex". Now, if you've installed the pandas 
>> library to a lib/ folder in your app's directory and added the folder to 
>> the python import path (sys.path), you'll be able to import pandas without 
>> an issue.
>>
>> And of course, you can use Compute Engine as well, depending on what 
>> exactly you'd prefer. What purpose are you deploying machines running 
>> pandas for? Maybe I could help if you've got questions about the trade-offs 
>> between a Flexible Environment and Compute Engine deployment.
>>
>> Cheers,
>>
>> Nick
>> Cloud Platform Community Support
>>
>> On Thursday, February 9, 2017 at 12:50:44 PM UTC-5, Juan Antonio 
>> Fernández Sánchez wrote:
>>>
>>> Hi everyone!
>>>
>>> I'm trying to run Pandas library in GAE app. I know that it use C 
>>> internally and I'm wondering if exist any simple solution to execute this 
>>> is GAE of if I've to think to deploy this microservice in a Compute Engine 
>>> container.
>>>
>>> Any help will be welcome, thank you so much!
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/319f1f75-d01c-4d7c-9d58-e54cf1cd97f7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
  • [google-appengine] U... Juan Antonio Fernández Sánchez
    • [google-appengi... 'Nick (Cloud Platform Support)' via Google App Engine
      • [google-app... Juan Antonio Fernández Sánchez
        • [google... 'Nick (Cloud Platform Support)' via Google App Engine
          • [go... Juan Antonio Fernández Sánchez
            • ... 'Nick (Cloud Platform Support)' via Google App Engine

Reply via email to