I am thinking about doing some test on app engine. And I have read about the library google has originally provided. I wonder what should I do if I want to use some external libraries that were installed before as part of Python2.7 such as Pyaudio and wx..
I was aware of that I should claim the library in the yaml file but what else do I need to do? Will naming and assigning a new environment variable help? If it does help, what paths should I include here? Thanks.
You should read up on the python sandbox and runtime restrictions, https://developers.google.com/appengine/docs/python/#Python_The_sandbox
This tells you how to use other libraries.
The libraries you list can not be used in appengine.
Also read up on 3rd party libraries that are directly supported https://developers.google.com/appengine/docs/python/tools/libraries27
Related
I would like to type in my Google Cloud function:
from my_google_cloud_project import another_google_cloud_func
another_google_cloud_func()
I don't want to invoke that function via HTTP request. How can I just import it?
Both functions are Google Cloud functions, but not just python code!
you can create a code.py file and write your code there
read the content of that file
with open('code.py') as f
content = f.read()
then execute those content using
exec(content)
Please read the official documentation regarding :
Packaging local dependencies
You can also package and deploy dependencies alongside your function.
This approach is useful if your dependency is not available via the
pip package manager or if your Cloud Functions environment's internet
access is restricted. For example, you might use a directory structure
such as the following:
You can then use code as usual from the included local dependency, localpackage. You can use this approach to bundle
any Python packages with your deployment.
I would like to know if there are any libraries that would be able to read blk00000.dat file. It can be either in Python or NodeJS libraries. Please recommend me some of the ones that you guys think is useful for working with blockchain.
For Python, bssdb, now deprecated, or the unofficial port for Python3, bssdb3, seem to be the only libraries for Berkeley DB in Python.
For NodeJS it seems the library for it is simply called berkeleydb
Also please note this is an off-topic post
I have built a Python application using an external library (lxml-module). This runs fine in my system. Is there any way to compile this code or package this code, so that I can run it in another system which does not have this external library (lxml-module) module installed in it?
If possible please give me a little reference on *.pyd also?
PyInstaller would be a good way to go to package your code.
It works in a configure/make/build workflow (before which you setup a small spec file with different kinds of options). The external package will be shipped along with your application.
lxml is supported in PyInstaller: http://www.pyinstaller.org/wiki/SupportedPackages.
As for being able to compile your code on another machine, Marcin had a good suggestion.
You can always copy the module to your local path and import it from there. Kind of what django did for json until it was included in the standard library.
This could do the trick:
try:
import lxml
except ImportError:
import myownmodules.lxml as lxml
I know this is the less "high tech" approach but if the problem is simple enough this is what I would do without a blink.
Besides .... our buddy Tim seems to agree: "If the implementation is easy to explain, it may be a good idea."
For Windows package up using py2exe, for OSX use py2app and for Linux possibly use cx_freeze
Is anyone using NLTK with GAE? From this thread it appears that GAE does not support NLTK (Special installation tricks needed.) Do you know any other lightweight similar Python module? Thanks.
GAE supports pretty much any "pure" Python modules which don't try to access files or sockets or other system level utilities. The poster from your link was mostly just trying to minimize the number of modules they included. They expressed a trial and error approach to figuring out which NLTK modules would be needed for their application. A slightly faster approach would be to download the whole NLTK package and move in all the ".py" files rather than just one at a time. There's no big downside to including modules you won't be using.
However this process is something of a fact of life with GAE. Any modules that aren't directly included in the GAE libraries need to be installed manually, and they need to be checked for any deviations from the GAE sandbox restrictions. See this.
A quick glance at the NLTK source code suggests that modules that depend on "mallet" in particular might be problematic, since this is compiled java code.
How should I install (or where should I put and organize) usual python libraries in Google App Engine.
Some libraries require to be installed using setuptools. How can I install that libraries.
You need to unpack the libraries into a subdirectory of your app, and add the library directory to the Python path in your request handler module. Any steps required by setup scripts, you'll have to execute manually, but there generally aren't any unless the library bundles a native module (which aren't supported on App Engine anyway).
If your library contains many files, it's possible to zip them and use zipimport, but that's somewhat more complex, and has performance implications.
For example, suppose you put a library in lib/mylibrary, under your app's directory. In your request handler module, add the following before any of your other imports:
import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), "lib/mylibrary"))
(Note that this assumes that your request handler is in the root directory of your app.)
Most of them can be installed using the pip.
Follow 3 first points from the Google wiki.