Domanda

How can I use an external library like requests in GAE with webapp? There are various related questions on SOF but none that answer my question specifically.

È stato utile?

Soluzione

You may to create dir in your project dir, let it will be distlibs. Than in main.py you should add this dir into sys.path:

import sys
sys.path[0:0] = ['distlibs']

than you can import libs from distlibs dir (for example wtforms):

from wtforms import validators
...

Update:

In the case of the requests lib, once you extract ithub(github.com/kennethreitz/requests) will find it has a directory called requests in it. That is what you need to put somewhere in your code.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top