googleapis / python-firestore

Apache License 2.0
218 stars 75 forks source link

Firestore Import Error in Debian 11 (Bullseye) with Python 3.9 #531

Closed jwainwright87 closed 2 years ago

jwainwright87 commented 2 years ago

Thanks for stopping by to let us know something could be better!

PLEASE READ: If you have a support contract with Google, please create an issue in the support console instead of filing on GitHub. This will ensure a timely response.

Please run down the following list and make sure you've tried the usual "quick fixes":

If you are still having issues, please be sure to include as much information as possible:

Environment details

Steps to reproduce

  1. Clean install of Raspberry Pi OS Lite (32-bit)
  2. sudo apt-get update && sudo apt-get upgrade (to latest version)
  3. Run pip install --upgrade firebase-admin

Code example

Import the module in python3 :

import firebase_admin
from firebase_admin import firestore

This is what happens:

>>> from firebase_admin import firestore
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/firebase_admin/firestore.py", line 22, in <module>
    from google.cloud import firestore # pylint: disable=import-error,no-name-in-module
  File "/usr/local/lib/python3.9/dist-packages/google/cloud/firestore.py", line 18, in <module>
    from google.cloud.firestore_v1 import __version__
  File "/usr/local/lib/python3.9/dist-packages/google/cloud/firestore_v1/__init__.py", line 30, in <module>
    from google.cloud.firestore_v1._helpers import GeoPoint
  File "/usr/local/lib/python3.9/dist-packages/google/cloud/firestore_v1/_helpers.py", line 22, in <module>
    from google.api_core import gapic_v1  # type: ignore
  File "/usr/local/lib/python3.9/dist-packages/google/api_core/gapic_v1/__init__.py", line 16, in <module>
    from google.api_core.gapic_v1 import config
  File "/usr/local/lib/python3.9/dist-packages/google/api_core/gapic_v1/config.py", line 23, in <module>
    import grpc
  File "/usr/local/lib/python3.9/dist-packages/grpc/__init__.py", line 23, in <module>
    from grpc._cython import cygrpc as _cygrpc
ImportError: /usr/local/lib/python3.9/dist-packages/grpc/_cython/cygrpc.cpython-39-arm-linux-gnueabihf.so: undefined symbol: __atomic_exchange_8

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.9/dist-packages/firebase_admin/firestore.py", line 28, in <module>
    raise ImportError('Failed to import the Cloud Firestore library for Python. Make sure '
ImportError: Failed to import the Cloud Firestore library for Python. Make sure to install the "google-cloud-firestore" module.

This is my pip list output:

CacheControl             0.12.10
cachetools               5.0.0
certifi                  2020.6.20
chardet                  4.0.0
colorzero                1.1
distro                   1.5.0
firebase-admin           5.2.0
google-api-core          2.5.0
google-api-python-client 2.36.0
google-auth              2.6.0
google-auth-httplib2     0.1.0
google-cloud-core        2.2.2
google-cloud-firestore   2.3.4
google-cloud-storage     2.1.0
google-crc32c            1.3.0
google-resumable-media   2.1.0
googleapis-common-protos 1.54.0
gpiozero                 1.6.2
grpcio                   1.43.0
grpcio-status            1.43.0
httplib2                 0.20.4
idna                     2.10
msgpack                  1.0.3
packaging                21.3
pip                      20.3.4
proto-plus               1.19.9
protobuf                 3.19.4
pyasn1                   0.4.8
pyasn1-modules           0.2.8
pyparsing                2.4.7
python-apt               2.2.1
requests                 2.25.1
RPi.GPIO                 0.7.0
rsa                      4.8
setuptools               52.0.0
six                      1.16.0
spidev                   3.5
ssh-import-id            5.10
uritemplate              4.1.1
urllib3                  1.26.5
wheel                    0.34.2

These are the things I have tried without success:

Making sure to follow these steps will guarantee the quickest resolution possible.

Thanks!

jwainwright87 commented 2 years ago

Looks as if this is grpc related.

This workaround resolved the issue: https://github.com/grpc/grpc/issues/25720#issuecomment-969002768

jwainwright87 commented 2 years ago

Here are the full steps I took to work around this issue for python Firestore running Raspberry Pi OS (Bullseye) and Python 3.9 on a Raspberry Pi 4.

Please follow ALL steps exactly:

You should now be able to run from firebase_admin import firestore in python now.

I don't take any credit for this fix. I have just patched the processes together to get Firebase working on the relevant OS and hardware.

See post above for link to the fix relating to grpc.

jwainwright87 commented 2 years ago

I've moved this back to open as I think this still needs looking into

jwainwright87 commented 2 years ago

Another update from further investigations into this issue.

It appears that libatomic.so.1 linking patch has been updated and is available in the latest pre-release version of grpc 1.44.0rc2.

Installing this via pip install grpcio --pre resolves any issues related to the firestore import.

Closing again.