This topic came up recently again in Reddit <http://reddit.com/pxqw75>. I 
answered there as well as this similar Q&A on SO 
<https://stackoverflow.com/a/69820884/305689>. The bottom line is that this 
shouldn't be an issue after 2018 when the 2nd-gen App Engine service 
launched. You don't have to use GAE flexible, and if you think you do, try 
Cloud Run 1st.

Cheers,
--Wesley

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"A computer never does what you want... only what you tell it."
    wesley chun :: @wescpy <http://twitter.com/wescpy> :: Software 
Architect & Engineer
    Developer Advocate at Google 
<https://cloud.google.com/developers/advocates/wesley-chun/> by day; at 
night: Core Python <http://amzn.com/dp/0132269937>


On Wednesday, February 15, 2017 at 3:10:19 PM UTC-8 pay...@google.com wrote:

> Hey Juan,
>
> In the App Engine Standard Environment 
> <https://cloud.google.com/appengine/docs/about-the-standard-environment>, 
> the docs explain that code and libraries must be pure python 
> <https://cloud.google.com/appengine/docs/python/runtime#Python_Pure_Python>
> :
>
> All code for the Python runtime environment must be pure Python, and not 
> include any C extensions or other code that must be compiled. 
>
>
> However, for the Flexible Environment 
> <https://cloud.google.com/appengine/docs/flexible/>, you can use C 
> modules, certainly, along with any code that would run on a linux machine. 
> The code runs inside a Docker container, but it's not quite the same as 
> deploying on a Compute Engine instance and is more like programming for App 
> Engine. 
>
> You should check out the quickstart for a Flexible Environment python app 
> <https://cloud.google.com/appengine/docs/flexible/python/quickstart> and 
> then see about reading my last comment which showed a Dockerfile which 
> would allow you to install libraries on the python instance container image.
>
>
> Cheers,
>
> Nick
> Cloud Platform Community Support
>
> On Wednesday, February 15, 2017 at 8:10:48 AM UTC-5, Juan Antonio 
> Fernández Sánchez wrote:
>>
>> Hi Nick, 
>>
>> Thank you for your answer. The problem is that I would like to run these 
>> libraries in a service inside a normal GAE app, not in a container in
>> Compute Engine. 
>>
>> Thanks!
>>
>> El lunes, 13 de febrero de 2017, 20:12:12 (UTC+1), Nick (Cloud Platform 
>> Support) escribió:
>>>
>>> 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 view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/6a29c018-86f3-48bd-95fb-c5017d6021d0n%40googlegroups.com.

Reply via email to