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.
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 creating a bot for Discord, and I just wrote this simple code:
import discord
TOKEN = "token"
client = discord.Client()
#client.event
async def on_ready():
print('Bot is ready.')
client.run(TOKEN)
and it produces the following error:
Traceback (most recent call last):
File "/Users/pcaires/Desktop/Programação/Python/Discord Bots/Main.py", line 1, in <module>
import discord
File "/Users/pcaires/Desktop/Programação/Python/Discord Bots/venv/lib/python3.7/site-packages/discord/__init__.py", line 20, in <module>
from .client import Client, AppInfo, ChannelPermissions
File "/Users/pcaires/Desktop/Programação/Python/Discord Bots/venv/lib/python3.7/site-packages/discord/client.py", line 38, in <module>
from .state import ConnectionState
File "/Users/pcaires/Desktop/Programação/Python/Discord Bots/venv/lib/python3.7/site-packages/discord/state.py", line 36, in <module>
from . import utils, compat
File "/Users/pcaires/Desktop/Programação/Python/Discord Bots/venv/lib/python3.7/site-packages/discord/compat.py", line 32
create_task = asyncio.async
^
SyntaxError: invalid syntax
I searched and searched in the internet, and most of the people say to use Python 3.7, and that's what I've been using. Also, I've been using PyCharm as my IDE for Python.
Where does the error come from?
The version of discord.py you are using does not support Python 3.7 (in which async becomes a reserved keyword), as explained in this issue.
This version of discord.py, which is the default branch on the GitHub repo, is sadly the one installed by Pip.
How to fix it
You can either:
downgrade your version of Python to 3.6.
install another version of discord.py, based on the rewrite branch which is under active development, for example with the command : python3 -m pip install --user -U https://github.com/Rapptz/discord.py/archive/rewrite.zip
You can manually edit the file and change that line from create_task = asyncio.async to create_task = getattr(asyncio, 'async')
See more info here: https://github.com/Rapptz/discord.py/issues/1249
Do NOT add asyncio in your requirements, it's already in Python (since 3.5).
It is only relevant for Python 3.3, which does not include asyncio in its stdlib.
As a quick fix you can change asyncio.async to asyncio.ensure_future in the installed offending module and run it. Obviously the right thing to do is get the module updated, but when that's not possible the above will get it running again.
fix it with
pip install --upgrade aiohttp
pip install --upgrade websockets
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'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 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