我正在嘗試將google-cloud-tasksPython 客戶端合并到我的 fastapi 應用程式中。但它給了我這樣的匯入錯誤:
from google.cloud import tasks_v2
ImportError: cannot import name 'tasks_v2' from 'google.cloud' (unknown location)
我的專案中的包,pip freeze:
aiohttp==3.8.1
aiosignal==1.2.0
async-timeout==4.0.2
attrs==21.4.0
boto3==1.20.51
botocore==1.23.51
CacheControl==0.12.10
cachetools==4.2.4
certifi==2021.10.8
charset-normalizer==2.0.11
click==7.1.2
confuse==1.4.0
firebase-admin==5.0.1
Flask==1.1.4
frozenlist==1.3.0
google-api-core==1.31.5
google-api-python-client==2.36.0
google-auth==1.35.0
google-auth-httplib2==0.1.0
google-cloud==0.34.0
google-cloud-core==2.2.2
google-cloud-firestore==2.3.4
google-cloud-storage==2.1.0
google-cloud-tasks==2.7.2
google-crc32c==1.3.0
google-resumable-media==2.2.0
googleapis-common-protos==1.54.0
greenlet==1.1.2
grpc-google-iam-v1==0.12.3
grpcio==1.43.0
grpcio-status==1.43.0
httplib2==0.20.4
idna==3.3
itsdangerous==1.1.0
Jinja2==2.11.3
jmespath==0.10.0
MarkupSafe==1.1.1
msgpack==1.0.3
multidict==6.0.2
numpy==1.22.2
packaging==21.3
pandas==1.3.2
proto-plus==1.20.0
protobuf==3.19.4
pyasn1==0.4.8
pyasn1-modules==0.2.8
pycryptodome==3.14.1
pyee==7.0.4
PyMySQL==1.0.2
pyparsing==3.0.7
python-dateutil==2.8.2
python-dotenv==0.19.1
pytz==2021.3
PyYAML==6.0
requests==2.27.1
rsa==4.8
s3transfer==0.5.1
schedule==1.1.0
six==1.16.0
slackclient==2.9.3
slackeventsapi==2.2.1
SQLAlchemy==1.4.22
uritemplate==4.1.1
urllib3==1.26.8
Werkzeug==1.0.1
yarl==1.7.2
我用于這個 virtualenv 的 Python 版本是Python 3.8.9
作業系統:macOS Monterey 12.1
在這里嘗試了這個解決方案,但沒有奏效。:(
uj5u.com熱心網友回復:
在網上做了一些更多的研究后,我意識到由于一些現有的包而錯過了一些包的安裝。這個問題幫助我意識到我需要重新排序google-cloud-tasks我的 requirements.txt 中的位置。所以我所做的非常簡單,創建了一個新的 virtualenvgoogle-cloud-tasks作為我的第一個包安裝,然后安裝了其他所有東西,最后問題解決了。
長話短說,問題是安裝包的順序,這就是為什么一些包被遺漏的原因。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/433872.html
上一篇:基于VM的自動縮放不應具有以下引數。standard_scheduler_settings.max_instances
