[英]ImportError: cannot import name 'tasks_v2' from 'google.cloud' (unknown location) in Python fastapi
I'm trying to incorporate google-cloud-tasks
Python client within my fastapi app.我正在尝试将
google-cloud-tasks
Python 客户端合并到我的 fastapi 应用程序中。 But it's giving me an import error like this:但它给了我这样的导入错误:
from google.cloud import tasks_v2
ImportError: cannot import name 'tasks_v2' from 'google.cloud' (unknown location)
packages in my project, pip freeze
:我项目中的包,
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
Python version I'm using for this virtualenv is Python 3.8.9
Python 我用于此 virtualenv 的版本是
Python 3.8.9
OS: macOS Monterey 12.1
操作系统:
macOS Monterey 12.1
Tried this solution here , but it didn't work. 在这里尝试了这个解决方案,但它没有用。 :(
:(
After doing some more research online I realized that installation of some packages is missed due to some existing packages.在网上做了更多研究后,我意识到由于一些现有的软件包而错过了一些软件包的安装。 This issue helped me realize I need to reorder the position of
google-cloud-tasks
in my requirements.txt. 这个问题帮助我意识到我需要在我的 requirements.txt 中重新排序 position 的
google-cloud-tasks
。 So what I did was pretty simple, created a new virtualenv installed google-cloud-tasks
as my first package and then installed everything else and finally the problem is solved.所以我做的很简单,创建一个新的 virtualenv 安装
google-cloud-tasks
作为我的第一个 package 然后安装其他所有东西,最后问题解决了。
Long story short the issue is the order in which packages are installed and that's why some packages are getting missed.长话短说,问题在于软件包的安装顺序,这就是为什么有些软件包会被遗漏的原因。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.