I am new to GAE. I wish to use the QuantLib python library (SWIG) as a module inside google app engine. I was following this blog post to set up QuantLib-SWIG on Ubuntu. http://blog.quantess.net/2012/09/26/quantlib-get-it-working-on-ubuntu/
I have compiled the modules for python using make -c Python after installing the required boost c++ libraries as mentioned in the post.
I've copied the QuantLib folder to my app folder. The QunatLib folder contains the following files:
__init__.py
__init__.pyc
QuantLib.py
QuantLib.pyc
_QuantLib.so*
This is my app directory structure:
app.yaml
index.py
QuantLib/
However, when I do an
import QunatLib
in the index.py in my app folder, I get the following error:
<type 'exceptions.ImportError'>: No module named _QuantLib
args = ('No module named _QuantLib',)
message = 'No module named _QuantLib'
I also get this is dev_appserver logs:
ImportError: No module named _QuantLib
_QuantLib is a .so file. Is there a way I can fix this problem? Or any other way to use QuantLib libraries for GAE?
Thanks.
No.
There are a limited number of 3rd party libraries that are not pure python. You cannot add your own non pure python libraries to appengine runtime.
Here is the current list of included 3rd party libs https://developers.google.com/appengine/docs/python/tools/libraries27
You can add any pure python libraries in your own code base.
Related
I have done the following, installed google cloud in a local lib folder with pip. Added an appengine_config.py file:
from google.appengine.ext import vendor
vendor.add("lib")
But still get:
ImportError: No module named google.cloud.bigquery
It seems there is some kind of conflict in the google namespace, since other dependendices in the lib folder seems to be possible to import.
If I just override with:
google.cloud.__path__ = ['/Users/okku/dev/MyServer/lib/google/cloud']
Then it works, but some other dependcy failes to be imported in this case google.api_core.
I have been on this for half day now. I cant find whats wrong. Any clues?
I installed the App engine SDK, then did a pip install requests and pip install requests-toolbelt (under VENV). when running the app in the local development server - I get the following error:
ERROR 2017-05-31 18:14:52,315 cgi.py:122] Traceback (most recent call last):
File "/Users/assafshamia/Freebird/Techradar/dev/scraper.py", line 8, in <module>
import requests
ImportError: No module named requests
I followed the steps of installing a 3rd party library (appengine_config.py and install requests under /lib)
what is going on???
I was able to resolve this by adding the following code to my Python app (main.py) in order to access the libraries at /lib:
import sys
sys.path.insert(0, 'lib')
Per the docs, you need to add the requests library code to your application directory. pip install is not enough.
You can include third party Python libraries with your application by
putting the code in your application directory.
Edit:
Additionally:
The include path of the Python module includes your application's root directory, which is the directory containing the app.yaml file. Python modules that you create in your application's root directory are available using a path from the root. Don't forget to create the required init.py files in your sub-directories so that Python recognizes those sub-directories as packages.
I currently have an app containing two modules, each with its own version number. When I run 'gcloud preview app deploy module1/app.yaml module2/app.yaml' I get the following error:
One or more files have conflicting settings for the [version] field.
If these version numbers need to be the same, is there a way to separately version your modules or is this not supported?
So it looks like I should not be naming my module configuration files 'app.yaml' (a reserved name). By naming the files 'module1.yaml' and 'module2.yaml' the problem was resolved.
I work on GAE project in PyDev
I'd like to use the PDFminer library in order to convert a pdf file to a text file.
My problem is when i run the application it dosn't work and it displays this error message :
ImportError: No module named pdfminer.converter
I tested the same code in a normale python project and it works fine.
I used the same code in python console and it works too
I add the pdfminer folder to the python interpreter, i removed the interpreter and i add it again but i have always the same error.
Really i don't what i have to do, can anybody help me please ?
The problem comes from the fact that the PDFMiner is a third party library i copied the PDFMiner's files into the project and i works fine GAE don't import lib if isn't a pure python even if it exits in PYTHONPATH I found the solution in this post: Google App Engine "no module named requests" PyDev
I downloaded and installed requests library for Python 2.7. Using the shell I can make "import requests" and actually use it without problems.
Thing is that when running Google App Engine it can't find it and prompts the error:
ImportError: No module named requests
I'm using PyDev-Eclipse as IDE for my project and tried adding the path (/usr/local/lib/python2.7/dist-packages/requests) both in
Project > properties > PyDev - PYTHONPATH > External Libraries
and in
Window > preferences > Pydev -Interpreter > Libraries
and none worked! Still having the same issue when trying to run my GAE app
Anyone could help?
Thanks!
Any 3rd party lib you use must be physically included in your project and deployed to appengine. This means it is not sufficient to just install with easy_install or pip
See the docs https://developers.google.com/appengine/docs/python/runtime#Pure_Python