I have trouble running a (working) python-script as the user www-data on a standard Raspi4-Debian-installation, which is necessary, since I want to run it from a php-file. I found a lot of questions regarding the same here, but I can't get it to work sadly. I'd be happy if somebody could help.
So, when I run my python-script on the commandline as myself it works perfectly.
When I start it with "sudo" oder "sudo -u www-data" I get the following error:
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 22, in <module>
from grpc import _compression
File "/usr/local/lib/python3.9/dist-packages/grpc/_compression.py", line 15, in <module>
from grpc._cython import 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 "/var/www/html/private/./weddingr_uploader2.py", line 26, in <module>
from firebase_admin import credentials, initialize_app, storage, firestore
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.
So I researched and thought: "okay, the user www-data" can't access the module google-cloud-firestore". I tried to deinstall it with
sudo pip3 uninstall google-cloud-firestore"
and installing it again with
sudo pip3 install google-cloud-firestore"
Although it tells me uninstall is successfull, when I install it again, it tells me, the requirement is already satisfied:
...
Requirement already satisfied: pyasn1<0.5.0,>=0.4.6 in /usr/local/lib/python3.9/dist-packages (from pyasn1-modules>=0.2.1->google-auth<3.0dev,>=1.25.0->google-api-core[grpc]!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.0,<3.0.0dev,>=1.31.5->google-cloud-firestore) (0.4.8)
Installing collected packages: google-cloud-firestore
Successfully installed google-cloud-firestore-2.5.3
I am running out of ideas, how to deinstall the module as my user and install it with su-rights in the correct path. Has somebody a hint in the right direction for me? Thanks!