简体   繁体   English

导入错误:无法从 Python fastapi 中的“google.cloud”(未知位置)导入名称“tasks_v2”

[英]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.

相关问题 ImportError:无法从“google.cloud”(未知位置)导入名称“aiplatform” - ImportError: cannot import name 'aiplatform' from 'google.cloud' (unknown location) 如何使用 google.cloud 修复 python“未解决的导入”错误 - How to fix python "unresolved import" -error with google.cloud ImportError:无法在 Google Cloud Language 中导入名称语言 API - ImportError: cannot import name language in Google Cloud Language API 无法在 python 脚本中使用 google.cloud(存储) - Unable to use google.cloud (storage) from within a python script go 1.18 在 google.cloud - go 1.18 in google.cloud AWS CDK - 导入错误:无法从“aws_cdk.cloud_assembly_schema”导入名称“AssetManifestOptions” - AWS CDK - ImportError: cannot import name 'AssetManifestOptions' from 'aws_cdk.cloud_assembly_schema' 尝试使用来自 google.cloud 的 BigQuery 时出现 ModuleNotFoundError - ModuleNotFoundError when trying to use BigQuery from google.cloud ImportError:无法为 Python 导入 Cloud Firestore 库。确保安装“google-cloud-firestore”模块 - ImportError: Failed to import the Cloud Firestore library for Python. Make sure to install the "google-cloud-firestore" module 无法导入 kats python 库:“ImportError:无法从‘ax.service.utils.instantiation’导入名称‘outcome_constraint_from_str’” - Cannot import kats python library: "ImportError: cannot import name 'outcome_constraint_from_str' from 'ax.service.utils.instantiation'" AppEngine Python 502 错误网关 - 导入错误:无法从“itsdangerous”导入名称“json” - AppEngine Python 502 Bad Gateway - ImportError: cannot import name 'json' from 'itsdangerous'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM