【问题标题】:Error import could not be resolved with Python错误导入无法用 Python 解决
【发布时间】:2022-02-28 16:58:07
【问题描述】:

我正在尝试将 Azure-storage-blob 与 Python 导入一起使用

from azure.storage.blob import BlobServiceClient, BlobClient, ContainerClient

并使用 pip install azure-storage-blob 安装在我的 .venv 中,并使用 azure-storage-blob 在 requirements.txt 中安装 这是我的环境点子列表

Package                   Version
------------------------- ---------
adal                      1.2.7
azure-common              1.1.28
azure-core                1.21.1
azure-cosmos              4.2.0
azure-functions           1.8.0
azure-mgmt-datalake-nspkg 3.0.1
azure-mgmt-nspkg          3.0.2
azure-mgmt-scheduler      2.0.0
azure-mgmt-search         2.1.0
azure-mgmt-servicebus     0.5.3
azure-mgmt-servicefabric  0.2.0
azure-mgmt-signalr        0.1.1
azure-mgmt-subscription   0.2.0
azure-mgmt-trafficmanager 0.50.0
azure-mgmt-web            0.35.0
azure-nspkg               3.0.2
azure-storage-blob        12.9.0
azure-storage-common      2.1.0
backcall                  0.2.0
certifi                   2021.10.8
cffi                      1.15.0
charset-normalizer        2.0.9
click                     8.0.4
colorama                  0.4.4
cryptography              36.0.1
cycler                    0.11.0
debugpy                   1.5.1
decorator                 5.1.0
entrypoints               0.3
fonttools                 4.28.5
idna                      3.3
ipykernel                 6.6.0
ipython                   7.30.1
isodate                   0.6.1
itsdangerous              2.1.0
jedi                      0.18.1
Jinja2                    3.0.3
jupyter-client            7.1.0
jupyter-core              4.9.1
msrest                    0.6.21
msrestazure               0.6.4
nest-asyncio              1.5.4
numpy                     1.21.5
oauthlib                  3.2.0
packaging                 21.3
pandas                    1.3.5
parso                     0.8.3
pickleshare               0.7.5
Pillow                    8.4.0
pip                       22.0.3
prompt-toolkit            3.0.24
pycparser                 2.21
pydocumentdb              2.3.5
Pygments                  2.11.0
PyJWT                     2.3.0
pymongo                   4.0.1
pyparsing                 3.0.6
python-dateutil           2.8.2
python-dotenv             0.19.2
pytz                      2021.3
pywin32                   303
pyzmq                     22.3.0
requests                  2.26.0
requests-oauthlib         1.3.1

但我得到无法解决导入“azure.storage.blob” 我该如何解决这个问题??

更新:它在我的 .venv 中不起作用,并且在 lib/site-package/azure 下没有“存储”文件夹

【问题讨论】:

  • 您确定您的环境在运行代码时已激活?
  • 是的,在终端中我看到 (.venv),它处于活动状态。
  • 当您实际运行代码时,您是否得到“导入“azure.storage.blob”无法解决”,或者它只是您的 IDE 给出的提示并且您的代码是否正确执行?我问的原因:stackoverflow.com/questions/64141052/…
  • 当我运行我的代码时,它说 ModuleNotFoundError: No module named 'azure.storage'。实际上,在 Lib/site-package/azure 下的 .venv 中,我没有看到“storage”文件夹,但是当尝试安装 azure-storage-blob 时,它说它已安装

标签: python azure pip azure-blob-storage azure-storage


【解决方案1】:

尝试以下任一方法解决Import "azure.storage.blob" could not be resolved错误:

1.如果您使用的是Visual Studio代码,请尝试以下命令安装azure-storage-blob

conda install -c anaconda azure conda install -c conda-forge azure-storage-blob  

2.卸载旧版本的azure-storage-blob’ and reinstall: pip uninstall azureandpip uninstall azure-storage`

在具体路径重新安装:

cdd .venv

pip install azure-storage –upgrade

参考:Unresolved import 'azure.storage.blob' when trying to use Python library azure-storage-blobHow to import Azure BlobService in python?Install Azure Python api on linux: importError: No module named storage.blob

【讨论】:

    【解决方案2】:

    感谢我解决重新创建 .venv 的所有人

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-08-19
      • 2022-06-17
      • 2019-01-19
      • 1970-01-01
      • 2021-11-20
      • 1970-01-01
      • 2018-09-07
      相关资源
      最近更新 更多