Im having trouble getting app engine to accept a 3rd party library.
ive copied it into the the app engine directory, but i keep getting the error, "invalid object, the library tweepy is not supported" in blah blah blah/app.yaml
could somebody point out the obvious mistake please?
thanks
ok, ive made a few changes to the code and now i get this error, hopefully it is more useful
2012-10-15 20:09:36 Running command: "['C:\\Python27\\pythonw.exe', 'C:\\Program Files\\Google\\google_appengine\\dev_appserver.py', '--admin_console_server=', '--port=8083', 'C:\\Documents and Settings\\ladds\\My Documents\\udacity\\whycantisigh']"
WARNING 2012-10-15 19:09:54,140 rdbms_mysqldb.py:74] The rdbms API is not available because the MySQLdb library could not be loaded.
WARNING 2012-10-15 19:09:56,171 datastore_file_stub.py:513] Could not read datastore data from c:\docume~1\ladds\locals~1\temp\dev_appserver.datastore
WARNING 2012-10-15 19:09:56,203 dev_appserver.py:3394] Could not initialize images API; you are likely missing the Python "PIL" module. ImportError: No module named _imaging
INFO 2012-10-15 19:09:56,328 dev_appserver_multiprocess.py:647] Running application dev~whycantisigh on port 8083: #http://localhost:8083
INFO 2012-10-15 19:09:56,328 dev_appserver_multiprocess.py:649] Admin console is available at: #http://localhost:8083/_ah/admin
WARNING 2012-10-15 19:10:26,171 py_zipimport.py:139] Can't open zipfile C:\Python27\lib\site-packages\oauth2-1.0.2-py2.7.egg: IOError: [Errno 13] file not accessible: 'C:\Python27\lib\site-packages\oauth2-1.0.2-py2.7.egg'
WARNING 2012-10-15 19:10:26,171 py_zipimport.py:139] Can't open zipfile C:\Python27\lib\site-packages\ply-3.4-py2.7.egg: IOError: [Errno 13] file not accessible: 'C:\Python27\lib\site-packages\ply-3.4-py2.7.egg'
WARNING 2012-10-15 19:10:26,187 py_zipimport.py:139] Can't open zipfile C:\Python27\lib\site-packages\tweepy-1.11-py2.7.egg: IOError: [Errno 13] file not accessible: 'C:\Python27\lib\site-packages\tweepy-1.11-py2.7.egg'
INFO 2012-10-15 19:10:30,171 dev_appserver.py:2884] "GET / HTTP/1.1" 405 -
INFO 2012-10-15 19:18:04,250 py_zipimport.py:148] zipimporter('C:\Python27\lib\site-packages\oauth2-1.0.2-py2.7.egg', '')
INFO 2012-10-15 19:18:04,250 py_zipimport.py:148] zipimporter('C:\Python27\lib\site-packages\ply-3.4-py2.7.egg', '')
INFO 2012-10-15 19:18:04,250 py_zipimport.py:148] zipimporter('C:\Python27\lib\site-packages\tweepy-1.11-py2.7.egg', '')
INFO 2012-10-15 19:18:06,640 dev_appserver.py:2884] "GET / HTTP/1.1" 405 -
im sorry its not formatted clearly, but it will only let me format the first line.
anyway, the gist of the problem seems to be that 3rd party libraries i have downloaded into python(and that work in the shell) arent accessible by app engine.
thanks
https://developers.google.com/appengine/kb/libraries
Many Native C Python modules are disabled with Google App Engine. The Python 2.7 runtime supports more modules than the Python 2.5 runtime.
It would help if you showed your app.yaml and the actual error message instead of blah blah blah.
But most likely you put tweepy in app.yaml and you don't need to.
Edit
To use 3rd party libraries with GAE, you need to put a copy of the library in your project folder. Otherwise, it won't get uploaded to the server on deploy. Installing it to your python path won't work.
Related
Setup: Run in Google Cloud Shell Standard Env
I tried to access firestore from the flask app using from google.cloud import firestore
I have installed it using pip install --upgrade google-cloud-firestore -t lib. If I run the script manually, it works fine. But when using dev_appserver.py, it fails. Got the error below.
$ dev_appserver.py app.yaml
INFO 2017-10-06 07:34:35,301 devappserver2.py:105] Skipping SDK update check.
INFO 2017-10-06 07:34:35,391 api_server.py:300] Starting API server at: http://0.0.0.0:34796
WARNING 2017-10-06 07:34:35,391 dispatcher.py:312] Your python27 micro version is below 2.7.12, our current production version.
INFO 2017-10-06 07:34:35,440 dispatcher.py:251] Starting module "default" running at: http://0.0.0.0:8080
INFO 2017-10-06 07:34:35,441 admin_server.py:116] Starting admin server at: http://0.0.0.0:8000
ERROR 2017-10-06 07:34:42,266 wsgi.py:263]
Traceback (most recent call last):
File "/google/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/google/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "/google/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 85, in LoadObject
obj = __import__(path[0])
File "/home/user1/projects/probfe/main.py", line 10, in <module>
from google.cloud import firestore
File "/google/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/python/runtime/sandbox.py", line 1132, in load_module
raise ImportError('No module named %s' % fullname)
ImportError: No module named google.gax
However, in my lib, I can see them.
$ls lib
builtins future-0.16.0.dist-info itsdangerous.pyc requests-2.18.4.dist-info
cachetools futures-3.1.1.dist-info jinja2 rsa
cachetools-2.0.1.dist-info google Jinja2-2.9.6.dist-info rsa-3.4.2.dist-info
certifi googleapis_common_protos-1.5.3.dist-info libfuturize setuptools
certifi-2017.7.27.1.dist-info googleapis_common_protos-1.5.3-py2.7-nspkg.pth libpasteurize setuptools-36.5.0.dist-info
chardet google_auth-1.1.1.dist-info _markupbase six-1.11.0.dist-info
chardet-3.0.4.dist-info google_auth-1.1.1-py2.7-nspkg.pth markupsafe six.py
click google_cloud_core-0.27.1.dist-info MarkupSafe-1.0.dist-info six.pyc
click-6.7.dist-info google_cloud_core-0.27.1-py3.6-nspkg.pth past socketserver
concurrent google_cloud_firestore-0.27.0.dist-info pkg_resources tests
copyreg google_cloud_firestore-0.27.0-py3.6-nspkg.pth ply _thread
dill google_gax-0.15.15.dist-info ply-3.8.dist-info tkinter
dill-0.2.7.1.dist-info google_gax-0.15.15-py2.7-nspkg.pth protobuf-3.4.0.dist-info urllib3
_dummy_thread grpc protobuf-3.4.0-py2.7-nspkg.pth urllib3-1.22.dist-info
easy_install.py grpcio-1.4.0.dist-info pyasn1 werkzeug
easy_install.pyc html pyasn1-0.3.7.dist-info Werkzeug-0.12.2.dist-info
enum http pyasn1_modules winreg
enum34-1.1.6.dist-info idna pyasn1_modules-0.1.4.dist-info xmlrpc
flask idna-2.6.dist-info queue
Flask-0.12.2.dist-info itsdangerous-0.24.dist-info reprlib
future itsdangerous.py requests
Since you're using dev_appserver.py it means you have a standard env application. And in the standard env all external dependencies need to be installed in your app, not on the local python instalation (which is what you did with your pip invocation).
From Installing a third-party library:
Create a directory to store your third-party libraries, such as lib/.
mkdir lib
Use pip (version 6 or later) with the -t <directory> flag to copy the libraries into the folder you created in the previous
step. For example:
pip install -t lib/ <library_name>
i'm just getting started using GAE, i have following guide in here https://developers.google.com/appengine/docs/go/gettingstarted/devenvironment and some hello word tutorial here https://developers.google.com/appengine/docs/go/gettingstarted/helloworld .
my problem is when i'm typing goapp serve it works. and show log like this:
INFO 2014-05-18 08:44:57,130 devappserver2.py:765] Skipping SDK update check.
WARNING 2014-05-18 08:44:57,135 api_server.py:374] Could not initialize images API; you are likely missing the Python "PIL" module.
INFO 2014-05-18 08:44:57,140 api_server.py:171] Starting API server at: http://localhost:59559
INFO 2014-05-18 08:44:57,154 dispatcher.py:182] Starting module "default" running at: http://localhost:8080
INFO 2014-05-18 08:44:57,156 admin_server.py:117] Starting admin server at: http://localhost:8000
but, when i'm trying to access http://localhost:8080 , it not show me "hello, world!" in the browser. and error log show me like this:
ERROR 2014-05-18 08:48:05,002 module.py:714] Request to '/' failed
Traceback (most recent call last):
File "/home/bayu/.go_appengine/google/appengine/tools/devappserver2/module.py", line 708, in _handle_request
environ, wrapped_start_response)
File "/home/bayu/.go_appengine/google/appengine/tools/devappserver2/request_rewriter.py", line 311, in _rewriter_middleware
response_body = iter(application(environ, wrapped_start_response))
File "/home/bayu/.go_appengine/google/appengine/tools/devappserver2/module.py", line 1228, in _handle_script_request
request_type)
File "/home/bayu/.go_appengine/google/appengine/tools/devappserver2/instance.py", line 382, in handle
request_type))
File "/home/bayu/.go_appengine/google/appengine/tools/devappserver2/http_proxy.py", line 148, in handle
connection.connect()
File "/home/bayu/.pyenv/versions/2.7.6/lib/python2.7/httplib.py", line 772, in connect
self.timeout, self.source_address)
File "/home/bayu/.pyenv/versions/2.7.6/lib/python2.7/socket.py", line 571, in create_connection
raise err
error: [Errno 111] Connection refused
INFO 2014-05-18 08:48:05,007 module.py:639] default: "GET / HTTP/1.1" 500 -
i have google it and trying another get started tutorial in here http://blog.joshsoftware.com/2014/03/12/learn-to-build-and-deploy-simple-go-web-apps-part-one/
but it's not work also.
what should i do?
i'm on ubuntu 12.04 , Python 2.7.3, go version go1.2.1 linux/386
using go_appengine_sdk_linux_386-1.9.4.zip
this is my hello.go and app.yaml
hello.go
package hello
import (
"fmt"
"net/http"
)
func init() {
http.HandleFunc("/", handler)
}
func handler(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, "Hello,")
}
app.yaml
application: helloworld
version: 1
runtime: go
api_version: go1
handlers:
- url: /.*
script: _go_app
thank you,
Not sure if this will help anyone or not but I came across the exact same issues and finally tracked it down to my hosts file. Basically what is happening is the app engine server is running on 0.0.0.0:8080 yet the interface / output is displaying localhost:8080. In my hosts file 0.0.0.0:8080 wasn't mapped to localhost so:
edit your /private/etc/hosts file with vim or whatever
add 0.0.0.0 localhost to your hosts file
save, start a new terminal and try and run you appengine server again
After that simple edit everything worked for me.
I create an app-engine endpoint api, which I am loading using GoogleAppengineLauncher. The api launches fine. But when I try to load api explorer for testing, I get an error due to the line from multiprocessing import Process. My research led me to this site. But that's not working for me. Does anyone know how to fix this?
from multiprocessing import Process
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/__init__.py", line 84, in <module>
import _multiprocessing
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/python/sandbox.py", line 861, in load_module
raise ImportError
ImportError
INFO 2013-03-25 23:46:32,229 server.py:528] "POST /_ah/spi/BackendService.getApiConfigs HTTP/1.1" 500 -
INFO 2013-03-25 23:46:32,229 server.py:528] "GET /_ah/api/discovery/v1/apis HTTP/1.1" 500 60
In this group thread, one of the Python 2.7 App Engine runtime engineer point out to alternatives (namely the futures package) that should work with the new Python 2.7 threading support.
Alternatively you could use the fetch_data_async functions to read from a blob without blocking.
fetch_data_rpc = blobstore.fetch_data_async(...)
other_processing()
upload_url = fetch_data_rpc.get_result()
I am trying to set up a Google CourseBuilder site on a RHEL server. I follow the instructions here and get the server running. However every request errors out with the following message. I have not changed any configuration from the provided package and a similar approach worked on Windows 8.
ERROR 2013-03-07 16:05:10,337 dev_appserver_import_hook.py:1251] Third party package markupsafe was enabled in app.yaml but not found on import. You may have to download and install it.
INFO 2013-03-07 16:05:10,412 dev_appserver.py:3104] "GET / HTTP/1.1" 302 -
What is strange is that the markupsafe package is already in .../google_appengine/lib/markupsafe-0.15
Any ideas how to fix this?
In the app.yaml file add the markupsafe library. For example:
libraries:
- name: jinja2
version: latest
- name: markupsafe
version: latest
I am trying to test a Google App Engine app with dev_appserver.py, but when I run import Crypto I get the following excerpted from the IOError (i.e. No access) traceback:
...
import Crypto
...
File "/System/Library/Frameworks/Python.framework/Versions
/2.7/lib/python2.7/zipfile.py", line 867, in read
return self.open(name, "r", pwd).read()
File "/System/Library/Frameworks/Python.framework/Versions
/2.7/lib/python2.7/zipfile.py", line 882, in open
zef_file = open(self.filename, 'rb')
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/
GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google
/appengine/tools/dev_appserver_import_hook.py", line 592, in __init__
raise IOError(errno.EACCES, 'file not accessible', filename)
IOError: [Errno 13] file not accessible: '/Library/Python/2.7/site-packages
/pycrypto-2.3-py2.7-macosx-10.7-intel.egg'
I am on Mac OS X 10.7, with Google App Engine 1.6.6 using Python 2.7.
Since PyCrypto is supported on Google App Engine, I would expect it to work on the development server.
I am aware that dev_appserver.py prevents loading external files. However, I noted that appengine/tools/dev_appserver_import_hook.py seems to have all the requisite files in the whitelist (e.g._fastmath).
Note, in app.yaml I have
libraries:
- name: pycrypto
version: latest
It seems as though I am missing something obvious but crucial. Any thoughts would be appreciated.
EDIT For more details see: https://code.google.com/p/googleappengine/issues/detail?id=12129
Yes, you have to install the third-party library yourself.
Google explains exactly which versions the provide on their platform,
so this should not be any problem.
The best way to get through this is create a virtual environment and install the pycrypto inside that. The reason your libraries inside app.yaml is not detected is most probably because you have multiple versions of python installed in your machine and the version you used to run the program might not be the same version where you installed the libraries