3

On their Built-in Third-party Libraries page, it says that lxml 3.7.3 is supported but I can't seem to find a way to use that.

If I write in app.yaml:

- name: lxml
  version: latest

When I log etree.LXML_VERSION inside the app, I get (2, 3, 0, 0).

Setting the version specifically to "3.7.3" (instead of latest) doesn't seem to work. When I try to deploy, gcloud says:

ERROR: (gcloud.app.deploy) An error occurred while parsing file: [... /app.yaml]
lxml version "3.7.3" is not supported, use one of: "2.3", "2.3.5"
  in "... app.yaml", line 17, column 1

I have installed lxml locally inside the ./lib folder, but the folder is ignored on deploy.

Am I doing something wrong?

Andrei Onel
  • 165
  • 1
  • 7
  • I believe you cannot use non-built-in Python modules that use C in App Engine so that is probably why it is being ignored. (The obvious exceptions to that are the built-in 3rd party libraries.) – mechanical_meat Nov 09 '17 at 17:12
  • Well, that's the thing. I'm trying to use a built-in library. And the docs says that app engine supports 3.7.3, but I can't seem to use that version. – Andrei Onel Nov 09 '17 at 17:24
  • Oh, I see that it is now supposed to be supported... https://cloud.google.com/appengine/docs/standard/python/tools/built-in-libraries-27 – mechanical_meat Nov 09 '17 at 17:33
  • See here: https://issuetracker.google.com/issues/68453375 – new name Nov 10 '17 at 13:07
  • Thanks for that link @JeffO'Neill. It actually gave me the idea to check the sdk version. My apt-get was not updating the gcloud sdk so I using an older version. – Andrei Onel Nov 13 '17 at 18:40

2 Answers2

1

The problems seemed to happen because of an old google cloud sdk.

The sdk was installed using apt-get and somehow it was not getting updated. This also included an older Python SDK

At this moment the latest Python SDK is 1.9.62, I was using 1.9.52.

Updating the sdk seemed to fix the problem

sudo apt-get update && sudo apt-get install google-cloud-sdk

Andrei Onel
  • 165
  • 1
  • 7
0

It wouldn't be the 1st time that inconsistencies exist between the documentation, what's included in the cloud SDK, what's included in the GAE language specific SDK and what's actually available on GAE (in production). See, for example, PyCharm - Can't create App Engine Application using DJango.

The deployment error message you got suggests that the 3.7.3 version doesn't actually exist on GAE, despite being marked as available in the documentation.

The lxml library is on the list of a few special libraries which need extra attention. Most likely because they aren't "pure Python code with no C extensions" and thus they can't be included in the SDKs with the other libraries, so they need to be installed separately on your local system. From Using built-in bundled libraries with the local development server (check that entire section for related info):

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:

Now, if you really want the 3.7.3 version, you may be out of luck: if indeed it's not "pure Python code with no C extensions" then you also won't be able to vendor it into your app either. Still, it's worth a try. A new try, note that you also need to:

  • take it out of the app.yaml file's libraries: section - you're not requesting a GAE-provided library anymore
  • complete the entire vendoring in procedure (you didn't mention creating the appengine_config.py file, for example).

If that doesn't work then you'll have to settle for one of the available versions mentioned in the deployment error messages. You'll need to:

  • add that version to the app.yaml file's libraries: section
  • install that version on your local system
  • drop the vendoring in attempt, if you went for it
Dan Cornilescu
  • 39,470
  • 12
  • 57
  • 97