I am trying to use the Human Api Python client with GAE.
I created a appengine_config.py and followed all instructions as described in Third-party Libraries in Python 2.7 documentation for GAE
My appengine_config.py looks like:
"""This file is loaded when starting a new application instance."""
from google.appengine.ext import vendor
# Add any libraries installed in the "lib" folder.
vendor.add('lib')
My requirements.txt looks like so:
HumanAPI
... and installs correctly:
Downloading/unpacking HumanAPI (from -r requirements.txt (line 1))
Downloading humanapi-0.1.10.tar.gz
Running setup.py (path:/private/var/folders/yq/s_1v2vtn2sxbtw_gz00q1r5w0000gp/T/pip_build_jimmykane/HumanAPI/setup.py) egg_info for package HumanAPI
Downloading/unpacking requests>=0.13.2 (from HumanAPI->-r requirements.txt (line 1))
Downloading requests-2.6.0-py2.py3-none-any.whl (469kB): 469kB downloaded
Downloading/unpacking docopt==0.4.0 (from HumanAPI->-r requirements.txt (line 1))
Downloading docopt-0.4.0.tar.gz
Running setup.py (path:/private/var/folders/yq/s_1v2vtn2sxbtw_gz00q1r5w0000gp/T/pip_build_jimmykane/docopt/setup.py) egg_info for package docopt
Installing collected packages: HumanAPI, requests, docopt
Running setup.py install for HumanAPI
Running setup.py install for docopt
Successfully installed HumanAPI requests docopt
Cleaning up...
But when I try to import:
from humanapi import get_authorize_url, get_auth_session
I get:
ERROR 2015-03-27 13:18:05,023 wsgi.py:263]
Traceback (most recent call last):
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 85, in LoadObject
obj = __import__(path[0])
File "/Users/jimmykane/projects/dimitrioskanellopoulos.com/main.py", line 2, in <module>
from controllers import server, auth, metrics
File "/Users/jimmykane/projects/dimitrioskanellopoulos.com/controllers/auth.py", line 9, in <module>
from humanapi import get_authorize_url, get_auth_session
File "/Users/jimmykane/projects/dimitrioskanellopoulos.com/lib/humanapi/__init__.py", line 1, in <module>
from .api import *
File "/Users/jimmykane/projects/dimitrioskanellopoulos.com/lib/humanapi/api.py", line 1, in <module>
import requests, os.path, logging, sys, time
File "/Users/jimmykane/projects/dimitrioskanellopoulos.com/lib/requests/__init__.py", line 58, in <module>
from . import utils
File "/Users/jimmykane/projects/dimitrioskanellopoulos.com/lib/requests/utils.py", line 26, in <module>
from .compat import parse_http_list as _parse_list_header
File "/Users/jimmykane/projects/dimitrioskanellopoulos.com/lib/requests/compat.py", line 42, in <module>
from .packages.urllib3.packages.ordered_dict import OrderedDict
File "/Users/jimmykane/projects/dimitrioskanellopoulos.com/lib/requests/packages/__init__.py", line 95, in load_module
raise ImportError("No module named '%s'" % (name,))
PIP version is 6.0.8
Anyone to help me solving this dependancy thingy or guide me to what I am doing wrong?
Thanks
Related
So, I'm trying to install ZPsycopgDA on Zope, but it keeps giving me the following error on the log file:
2022-02-13T02:11:01 ERROR Application Couldn't install ZPsycopgDA
Traceback (most recent call last):
File "/home/rubens/zope/lib64/python2.7/site-packages/OFS/Application.py", line 660, in install_product
global_dict, global_dict, silly)
File "/home/rubens/zope/instance/Products/ZPsycopgDA/__init__.py", line 21, in <module>
import DA
File "/home/rubens/zope/instance/Products/ZPsycopgDA/DA.py", line 21, in <module>
import db
File "/home/rubens/zope/instance/Products/ZPsycopgDA/db.py", line 18, in <module>
from Shared.DC.ZRDB.TM import TM
ImportError: No module named ZRDB.TM
I added the Zope lib directory to PYTHONPATH (/home/rubens/zope/lib64) as instructed, but still gives me this error. Any clues? I'm using Zope2==2.13.30.
Found the solution. Had to install Products.ZSQLMethods (pip install Products.ZSQLMethods==2.13.4). I've installed this version because of Zope2==2.13.30 compatibility.
I'm using Appengine cron job to schedule cloud function and when I deploy and try to run a job, getting below error. Any idea what could be wrong here? Followed steps from [here][1]
(/base/alloc/tmpfs/dynamic_runtimes/python27/a7637d5531ec9deb_unzipped/python27_lib/versions/1/google/appengine/runtime/wsgi.py:263)
Traceback (most recent call last):
File "/base/alloc/tmpfs/dynamic_runtimes/python27/a7637d5531ec9deb_unzipped/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/base/alloc/tmpfs/dynamic_runtimes/python27/a7637d5531ec9deb_unzipped/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "/base/alloc/tmpfs/dynamic_runtimes/python27/a7637d5531ec9deb_unzipped/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 85, in LoadObject
obj = __import__(path[0])
File "/base/data/home/apps/s~zion-hymns/20180222t221057.407849847593018575/main.py", line 18, in <module>
import pubsub_utils
File "/base/data/home/apps/s~zion-hymns/20180222t221057.407849847593018575/pubsub_utils.py", line 24, in <module>
import oauth2client.contrib.appengine as gae_oauth2client
File "./lib/oauth2client/contrib/appengine.py", line 36, in <module>
from oauth2client import client
File "./lib/oauth2client/client.py", line 39, in <module>
from oauth2client import transport
File "./lib/oauth2client/transport.py", line 255, in <module>
redirections=httplib2.DEFAULT_MAX_REDIRECTS,
AttributeError: 'module' object has no attribute 'DEFAULT_MAX_REDIRECTS'
[1]: https://firebase.googleblog.com/2017/03/how-to-schedule-cron-jobs-with-cloud.html?utm_campaign=culture_education_functions_en_06-29-17&utm_source=Firebase&utm_medium=yt-desc
Seems that I found the problem. Which version of Python your pip is using? In my case it was 3.6 despite the fact that the Python itself was 2.7
So the problem was that pip downloaded a Python 3.6 syntax version of httplib2, it was uploaded to the Google App Engine, which use Python 2.7. It tried to load in the module and fail miserably.
Try this :
Check the vesionn of your pip with :
pip -V
If you see some thing like pip 9.0.1 from /bla/bla/lib/python3.6/site-packages (python 3.6) then continue
Install pip for python 2.7 (it should be in the Python2.7 installation pachage under bin folder)
Remove old lib folder in your project
Run pip install -t lib -r requirements.txt (make sure that this pip is the right 2.7 version)
Deploy
By doing that you are using the right version of the lib and it should be working.
Hope it will help.
I have used to below firebase blog link to execute a cron job on google cloud app engine for firebase functions but i am getting the below error.
Firebase Blog link
Please help..
22:47:33.468
(/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py:263)
Traceback (most recent call last):
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 85, in LoadObject
obj = __import__(path[0])
File "/base/data/home/apps/s~updateroom-1a8fe/20170705t224250.402458509646721682/main.py", line 18, in <module>
import pubsub_utils
File "/base/data/home/apps/s~updateroom-1a8fe/20170705t224250.402458509646721682/pubsub_utils.py", line 23, in <module>
import httplib2
File "./lib/httplib2/__init__.py", line 352
print('%s:' % h, end=' ', file=self._fp)
^
SyntaxError: invalid syntax
print('%s:' % h, end=' ', file=self._fp) is valid python3, but not valid python2.
You can either do a future import to use this syntax in python2:
from __future__ import print_function
or use the old print syntax.
UPDATE
Reviewing this, I noticed that the offending line of code is in library code: ./lib/httplib2/__init__.py
So the problem is that your httplib2 installation is the python3 version rather than the python2 version.
You can try reinstalling your vendored packages to fix this; the command will be
pip install -r <name-of-your-vendored-requirements-file> -t lib
Ensure that you are using the right version of pip: pip --version should point to a location within a python2 installation.
I'm just trying to run the simple hello world app on their tutorials page. I used to use Google App Engine frequently, but now I can't seem to get it going at all. I'm on win 10 x64. Downloaded latest google cloud sdk, and python version 2.7.13
> ERROR 2017-01-07 15:25:21,219 wsgi.py:263] Traceback (most recent
> call last): File "C:\Program Files (x86)\Google\Cloud
> SDK\google-cloud-sdk\platform\google_appengine\google\appengine\runtime\wsgi.py",
> line 240, in Handle
> handler = _config_handle.add_wsgi_middleware(self._LoadHandler()) File "C:\Program Files (x86)\Google\Cloud
> SDK\google-cloud-sdk\platform\google_appengine\google\appengine\runtime\wsgi.py",
> line 299, in _LoadHandler
> handler, path, err = LoadObject(self._handler) File "C:\Program Files (x86)\Google\Cloud
> SDK\google-cloud-sdk\platform\google_appengine\google\appengine\runtime\wsgi.py",
> line 85, in LoadObject
> obj = __import__(path[0]) File "C:\....\python-docs-samples\appengine\standard\flask\hello_world\main.py",
> line 18, in <module>
> from flask import Flask File "C:\....\python-docs-samples\appengine\standard\flask\hello_world\lib\flask\__init__.py",
> line 21, in <module>
> from .app import Flask, Request, Response File "C:\....\python-docs-samples\appengine\standard\flask\hello_world\lib\flask\app.py",
> line 27, in <module>
> from . import json, cli File "C:\....\python-docs-samples\appengine\standard\flask\hello_world\lib\flask\cli.py",
> line 17, in <module>
> import click File "C:\....\python-docs-samples\appengine\standard\flask\hello_world\lib\click\__init__.py",
> line 18, in <module> INFO 2017-01-07 10:25:21,229 module.py:806]
> default: "GET / HTTP/1.1" 500 -
> from .core import Context, BaseCommand, Command, MultiCommand, Group, \ File
> "C:\....\python-docs-samples\appengine\standard\flask\hello_world\lib\click\core.py", line 8, in <module>
> from .types import convert_type, IntRange, BOOL File "C:\....\python-docs-samples\appengine\standard\flask\hello_world\lib\click\types.py",
> line 4, in <module>
> from ._compat import open_stream, text_type, filename_to_ui, \ File
> "C:\....\python-docs-samples\appengine\standard\flask\hello_world\lib\click\_compat.py",
> line 536, in <module>
> from ._winconsole import _get_windows_console_stream File "C:\....\python-docs-samples\appengine\standard\flask\hello_world\lib\click\_winconsole.py",
> line 16, in <module>
> import ctypes File "C:\Python27\lib\ctypes\__init__.py", line 7, in <module>
> from _ctypes import Union, Structure, Array File "C:\Program Files (x86)\Google\Cloud
> SDK\google-cloud-sdk\platform\google_appengine\google\appengine\tools\devappserver2\python\sandbox.py",
> line 964, in load_module
> raise ImportError('No module named %s' % fullname)
ImportError: No module named _ctypes
Google's sample Flask "Hello World" application requires Flask 0.11.1.
This library is not vendored by Google, so developers are required to install it via pip
This sample shows how to use Flask with Google App Engine Standard.
Before running or deploying this application, install the dependencies
using pip:
pip install -t lib -r requirements.txt
Flask's setup.py instructs pip to install the click library, at a release later than or equal to version 2.0.
install_requires=[
'Werkzeug>=0.7',
'Jinja2>=2.4',
'itsdangerous>=0.21',
'click>=2.0',
],
In November 2015 a change was committed to click to improve support for unicode in the windows console. This change added the import of the ctypes library which Appengine is choking on, because the Appengine sandbox does not allow importing ctypes.
The workaround for this is to overwrite the installed click with an earlier version (5.1 looks like the most recent candidate):
pip install --target lib --upgrade click==5.1
For me, the workaround mentioned here Google's issue tracker worked
goto [sdk_home]\google\appengine\tools\devappserver2\python\sandbox.py
find the definition of _WHITE_LIST_C_MODULES = [xxx]
add following two lines to the list:
'_winreg',
'_ctypes',
try your app again.
The issue was marked fixed on 7/7/2017.
I have recently updated my environment using gcloud component update. I am now having the following issue:
xxxxxx-MacBook-Air:~ poiuytrez$ dev_appserver.py .
Traceback (most recent call last):
File "/usr/local/bin/dev_appserver.py", line 83, in <module>
_run_file(__file__, globals())
File "/usr/local/bin/dev_appserver.py", line 79, in _run_file
execfile(_PATHS.script_file(script_name), globals_)
File "/Applications/Miscelaneous/google-cloud-sdk/.install/.backup/platform/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 36, in <module>
from google.appengine.tools.devappserver2 import dispatcher
File "/Applications/Miscelaneous/google-cloud-sdk/.install/.backup/platform/google_appengine/google/appengine/tools/devappserver2/dispatcher.py", line 29, in <module>
from google.appengine.tools.devappserver2 import module
File "/Applications/Miscelaneous/google-cloud-sdk/.install/.backup/platform/google_appengine/google/appengine/tools/devappserver2/module.py", line 75, in <module>
from google.appengine.tools.devappserver2 import vm_runtime_factory
File "/Applications/Miscelaneous/google-cloud-sdk/.install/.backup/platform/google_appengine/google/appengine/tools/devappserver2/vm_runtime_factory.py", line 25, in <module>
from google.appengine.tools.devappserver2 import vm_runtime_proxy
File "/Applications/Miscelaneous/google-cloud-sdk/.install/.backup/platform/google_appengine/google/appengine/tools/devappserver2/vm_runtime_proxy.py", line 29, in <module>
from google.appengine.tools.devappserver2 import log_manager
File "/Applications/Miscelaneous/google-cloud-sdk/.install/.backup/platform/google_appengine/google/appengine/tools/devappserver2/log_manager.py", line 34, in <module>
from google.appengine.tools.docker import containers
File "/Applications/Miscelaneous/google-cloud-sdk/.install/.backup/platform/google_appengine/google/appengine/tools/docker/containers.py", line 48, in <module>
from docker import docker
ImportError: cannot import name docker
I am not sure what to do.
As per Google Cloud SDK - Release Notes for 0.9.68 (2015/07/08)
The standalone App Engine SDKs are no longer distributed through the Cloud SDK.
App Engine functionality can still be used through the gcloud preview app command group.
The gae-java, gae-python, gae-php, and gae-go components no longer exist in the component manager.
If you need to use appcfg or dev_appserver directly, these are still
available in the App Engine SDK downloads that can be found here:
https://cloud.google.com/appengine/downloads
So your options are:
Run gcloud preview app run app.yaml from your project's home directory
Install the Google App Engine SDK for python and use its bundled dev_appserver
Install docker-py to "fix" it.
More info in this bug report