We have an application that uses firestore. It is running on Python 3.x on standard Google app engine. The application was running fine, till this morning when we tried to run the new version. The deployment of the new version is executed without any error. The requirement.txt is as follows -
firebase_admin==3.0.0
sendgrid==6.9.3
google-auth==1.35.0
google-auth-httplib2==0.1.0
jinja2==3.0.3
MarkupSafe==2.0.1
pytz==2021.3
Flask==2.0.2
twilio==6.46.0
httplib2==0.20.2
requests==2.24.0
requests_toolbelt==0.9.1
google-cloud-tasks==2.7.1
google-cloud-logging==1.15.1
googleapis-common-protos==1.54.0
protobuf==3.20.1
We get the following error.
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/google/cloud/firestore_v1/services/firestore/client.py", line 55, in <module>
from google.cloud.location import locations_pb2 # type: ignore
ModuleNotFoundError: No module named 'google.cloud.location'
Please help.
Updated (9-24-2022) with the complete error output.
Traceback (most recent call last):
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/gunicorn/arbiter.py", line 589, in spawn_worker
worker.init_process()
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/gunicorn/workers/gthread.py", line 92, in init_process
super().init_process()
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/gunicorn/workers/base.py", line 134, in init_process
self.load_wsgi()
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi
self.wsgi = self.app.wsgi()
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 58, in load
return self.load_wsgiapp()
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
return util.import_app(self.app_uri)
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/gunicorn/util.py", line 359, in import_app
mod = importlib.import_module(module)
File "/opt/python3.7/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/srv/main.py", line 8, in <module>
from controllers import server, common, header
File "/srv/controllers/server.py", line 19, in <module>
from controllers import basehandler
File "/srv/controllers/basehandler.py", line 12, in <module>
from google.cloud import firestore
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/google/cloud/firestore/__init__.py", line 18, in <module>
from google.cloud.firestore_v1 import __version__
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/google/cloud/firestore_v1/__init__.py", line 36, in <module>
from google.cloud.firestore_v1.async_client import AsyncClient
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/google/cloud/firestore_v1/async_client.py", line 45, in <module>
from google.cloud.firestore_v1.async_transaction import AsyncTransaction
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/google/cloud/firestore_v1/async_transaction.py", line 49, in <module>
from google.cloud.firestore_v1.client import Client
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/google/cloud/firestore_v1/client.py", line 44, in <module>
from google.cloud.firestore_v1.services.firestore import client as firestore_client
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/google/cloud/firestore_v1/services/firestore/__init__.py", line 16, in <module>
from .client import FirestoreClient
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/google/cloud/firestore_v1/services/firestore/client.py", line 55, in <module>
from google.cloud.location import locations_pb2 # type: ignore
ModuleNotFoundError: No module named 'google.cloud.location'
It looks like Google made a mistake in setting requirements for one its Python packages.
If you create a new virtual environment, install with pip install -r you should be able to recreate the error you are seeing in production.
To fix it, I would do pip list on your local machine (in the environment that is still working) and add fixed versions of other installed google packages until it works.
You can test by creating a new Python virtual environment, installing with pip install -r and seeing if it works.
It is a tedious process unfortunately.
I got this exact same error just now while trying to link a Python script to Firestore. I don't know if this is a "correct" solution but I got my code to run and save data to my Firestore database after this doing this.
In the error message, this line specifies the file where google.cloud.location is being imported:
File "/layers/google.python.pip/pip/lib/python3.10/site-packages/google/cloud/firestore_v1/services/firestore/client.py", line 55, in <module>
If you open the client.py file and comment out the line 55 ("from google.cloud.location import locations_pb2 # type: ignore"), then run your code again, the next error message will show the other file where google.cloud.location is being imported. Repeat this process for all five files where this module is imported. (client.py, base.py, grpc.py, grpc_asyncio.py, async_client.py)
From searching through the code, I'm seeing that locations_pb2 (imported from google.cloud.location) is never used. I suspect that commenting this out entirely won't affect the functionality of firebase_admin.
Related
Can anybody help figuring out the issue and solution.Here is the error for python 3.10.6 and django 3.2.17
python manage.py runserver 0.0.0.0:8001
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
File "/usr/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
self.run()
File "/usr/lib/python3.10/threading.py", line 953, in run
self._target(*self._args, **self._kwargs)
File "/home/mindmatrix/Documents/demo/lib/python3.10/site- packages/django/utils/autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "/home/mindmatrix/Documents/demo/lib/python3.10/site-packages/django/core/management/commands/runserver.py", line 110, in inner_run
autoreload.raise_last_exception()
File "/home/mindmatrix/Documents/demo/lib/python3.10/site-packages/django/utils/autoreload.py", line 87, in raise_last_exception
raise _exception[1]
File "/home/mindmatrix/Documents/demo/lib/python3.10/site-packages/django/core/management/__init__.py", line 375, in execute
autoreload.check_errors(django.setup)()
File "/home/mindmatrix/Documents/demo/lib/python3.10/site-packages/django/utils/autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "/home/mindmatrix/Documents/demo/lib/python3.10/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/mindmatrix/Documents/demo/lib/python3.10/site-packages/django/apps/registry.py", line 114, in populate
app_config.import_models()
File "/home/mindmatrix/Documents/demo/lib/python3.10/site-packages/django/apps/config.py", line 301, in import_models
self.models_module = import_module(models_module_name)
File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/home/mindmatrix/Documents/job_portal_updated_Feb_10/peeldb/models.py", line 8, in <module>
from oauth2client.contrib.django_util.models import CredentialsField
File "/home/mindmatrix/Documents/demo/lib/python3.10/site-packages/oauth2client/contrib/django_util/__init__.py", line 233, in <module>
from django.core import urlresolvers
ImportError: cannot import name 'urlresolvers' from 'django.core' (/home/mindmatrix/Documents/demo/lib/python3.10/site-packages/django/core/__init__.py)
I am trying for version upgrade of the open source project. I have upgraded all the neccessary requirements for the project. Now while running the command python manage.py runserver I am facing this issue.If any one can help?? I`
`when i run line of code: python manage.py startapp blog error below displays
Traceback (most recent call last):
File "C:\Users\lenevo\Desktop\portfolio-project\manage.py", line 22, in <module>
main()
File "C:\Users\lenevo\Desktop\portfolio-project\manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "C:\Users\lenevo\Desktop\reemaenv\Lib\site-packages\django\core\management_init_.py", line 381, in execute_from_command_line
utility.execute()
File "C:\Users\lenevo\Desktop\reemaenv\Lib\site-packages\django\core\management_init_.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\lenevo\Desktop\reemaenv\Lib\site-packages\django\core\management\base.py", line 336, in run_from_argv
connections.close_all()
File "C:\Users\lenevo\Desktop\reemaenv\Lib\site-packages\djayour textngo\db\utils.py", line 224, in close_all
connection.close()
File "C:\Users\lenevo\Desktop\reemaenv\Lib\site-packages\django\db\backends\sqlite3\base.py", line 248, in close
if not self.is_in_memory_db():
^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\lenevo\Desktop\reemaenv\Lib\site-packages\django\db\backends\sqlite3\base.py", line 367, in is_in_memory_db
return self.creation.is_in_memory_db(self.settings_dict['NAME'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\lenevo\Desktop\reemaenv\Lib\site-packages\django\db\backends\sqlite3\creation.py", line 12, in is_in_memory_db
return database name == ':memory:' or 'mode=memory' in database name
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Type Error: argument of type 'Windows Path' is not Iterable
plz help me solve this problem `
I am working on django project. And testing Sql Server database.
I am using korean linux hosting service gabia. So I don't have any root access.
Even this hosting company blocked yum and rpm.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: libodbc.so.2: cannot open shared object file: No such file or directory
I am keep having this kind of trouble when I import pyodbc. But I can fully use pymssql module.
I have no idea what is wrong with this linux...
This is when I connect django to mssql database with mssql-django package.
Traceback (most recent call last):
File "/web/.local/lib/python3.9/site-packages/mssql/base.py", line 16, in <module>
import pyodbc as Database
ImportError: libodbc.so.2: cannot open shared object file: No such file or directory
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/wsgiref/handlers.py", line 137, in run
self.result = application(self.environ, self.start_response)
File "/web/.local/lib/python3.9/site-packages/django/core/handlers/wsgi.py", line 130, in __call__
signals.request_started.send(sender=self.__class__, environ=environ)
File "/web/.local/lib/python3.9/site-packages/django/dispatch/dispatcher.py", line 176, in send
return [
File "/web/.local/lib/python3.9/site-packages/django/dispatch/dispatcher.py", line 177, in <listcomp>
(receiver, receiver(signal=self, sender=sender, **named))
File "/web/.local/lib/python3.9/site-packages/django/db/__init__.py", line 46, in reset_queries
for conn in connections.all():
File "/web/.local/lib/python3.9/site-packages/django/utils/connection.py", line 76, in all
return [self[alias] for alias in self]
File "/web/.local/lib/python3.9/site-packages/django/utils/connection.py", line 76, in <listcomp>
return [self[alias] for alias in self]
File "/web/.local/lib/python3.9/site-packages/django/utils/connection.py", line 62, in __getitem__
conn = self.create_connection(alias)
File "/web/.local/lib/python3.9/site-packages/django/db/utils.py", line 208, in create_connection
backend = load_backend(db["ENGINE"])
File "/web/.local/lib/python3.9/site-packages/django/db/utils.py", line 113, in load_backend
return import_module("%s.base" % backend_name)
File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 850, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "/web/.local/lib/python3.9/site-packages/mssql/base.py", line 18, in <module>
raise ImproperlyConfigured("Error loading pyodbc module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading pyodbc module: libodbc.so.2: cannot open shared object file: No such file or directory
This linux is CentOS 7
I've tried to install unixODBC on /web/.local directory which I can access into. And I successfully executed unixodbc alone, but not with python pyodbc.
I failed to install FreeTDS because I cannot find any way to install FreeTDS on this linux with tar file.
I wonder if I can change the installation path written on pyodbc package file. If I can, then I can fix this problem with changing the installation root of unixODBC to my accessable directory.
Django 1.10
django-debug-toolbar==1.5
I am working on a new project (I've just installed Django). Trying to install Django Debug Toolbar.
Documentation: https://django-debug-toolbar.readthedocs.io/en/stable/installation.html#prerequisites
According to the documentation, this release of the django-debug-toolbar is compatible with Django 1.10.
What have I done wrong?
settings.py
# { django-debug-toolbar
DEBUG_TOOLBAR_PATCH_SETTINGS = False
INTERNAL_IPS = ['127.0.0.1', ]
if DEBUG:
MIDDLEWARE += ['debug_toolbar.middleware.DebugToolbarMiddleware',]
INSTALLED_APPS += ['debug_toolbar',]
# } django-debug-toolbar
urls.py
from django.conf import settings
from django.conf.urls import include
if settings.DEBUG:
import debug_toolbar
urlpatterns += [
url(r'^__debug__/', include(debug_toolbar.urls)),
]
Traceback
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x7f97d6ab9840>
Traceback (most recent call last):
File "/home/michael/workspace/venv/photoarchive/lib/python3.5/site-packages/django/utils/autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "/home/michael/workspace/venv/photoarchive/lib/python3.5/site-packages/django/core/management/commands/runserver.py", line 142, in inner_run
handler = self.get_handler(*args, **options)
File "/home/michael/workspace/venv/photoarchive/lib/python3.5/site-packages/django/contrib/staticfiles/management/commands/runserver.py", line 27, in get_handler
handler = super(Command, self).get_handler(*args, **options)
File "/home/michael/workspace/venv/photoarchive/lib/python3.5/site-packages/django/core/management/commands/runserver.py", line 64, in get_handler
return get_internal_wsgi_application()
File "/home/michael/workspace/venv/photoarchive/lib/python3.5/site-packages/django/core/servers/basehttp.py", line 49, in get_internal_wsgi_application
return import_string(app_path)
File "/home/michael/workspace/venv/photoarchive/lib/python3.5/site-packages/django/utils/module_loading.py", line 20, in import_string
module = import_module(module_path)
File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 665, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "/home/michael/workspace/photoarchive/photoarchive/wsgi.py", line 16, in <module>
application = get_wsgi_application()
File "/home/michael/workspace/venv/photoarchive/lib/python3.5/site-packages/django/core/wsgi.py", line 14, in get_wsgi_application
return WSGIHandler()
File "/home/michael/workspace/venv/photoarchive/lib/python3.5/site-packages/django/core/handlers/wsgi.py", line 153, in __init__
self.load_middleware()
File "/home/michael/workspace/venv/photoarchive/lib/python3.5/site-packages/django/core/handlers/base.py", line 82, in load_middleware
mw_instance = middleware(handler)
TypeError: __init__() takes 1 positional argument but 2 were given
Django 1.10 introduced new style of middleware:
https://docs.djangoproject.com/en/1.10/releases/1.10/#new-style-middleware
There was a bug in django-debug-toolbar related to that change. The bug is now fixed in version 1.6 or later, so just use the latest version released to PyPI.
If you must use versions of django-debug-toolbar older than 1.6 with Django 1.10 or later, you can change MIDDLEWARE to MIDDLEWARE_CLASSES in the Django settings.
I changed MIDDLEWARE to MIDDLEWARE_CLASSES in settings.py.
It's work for me!
Already fixed. There is no need to rename MIDDLEWARE. Just install directly from git:
pip install https://github.com/jazzband/django-debug-toolbar/archive/master.zip
And instead of stable use the latest docs:
http://django-debug-toolbar.readthedocs.io/en/latest/
I was following the outlines of this guide (http://www.instructables.com/id/Aquaponics-Online-Temperature-and-Humidity/step3/Testing-GAE-SDK/), so I can try to innovate the design for my own aquaponic system.
However, when I typed "$ python2.7 AppEngine/dev_appserver.py IAquaponics_DHT/myapsystem" into my terminal, I received an error: http://i.imgur.com/ueO4MA1.jpg (my stacktrace is below).
note: "__" is to blank out my name.
____#____-Linux:~$ python2.7 AppEngine/dev_appserver.py
Traceback (most recent call last):
File "AppEngine/dev_appserver.py", line 182, in <module>
_run_file(__file__, globals())
File "AppEngine/dev_appserver.py", line 178, in _run_file
execfile(script_path, globals_)
File "/home/____/AppEngine/google/appengine/tools/devappserver2/devappserver2.py", line 32, in <module>
from google.appengine.tools.devappserver2.admin import admin_server
File "/home/____/AppEngine/google/appengine/tools/devappserver2/admin/admin_server.py", line 25, in <module>
import webapp2
File "/home/____/AppEngine/lib/webapp2-2.5.1/webapp2.py", line 25, in <module>
import webob
File "/home/____/AppEngine/lib/webob-1.2.3/webob/__init__.py", line 3, in <module>
from webob.response import *
File "/home/____/AppEngine/lib/webob-1.2.3/webob/response.py", line 9, in <module>
import zlib
ImportError: No module named zlib
Have you tried (run enter this in the terminal window to install the install a package for zlib)
sudo apt-get install zlib
start there