【问题标题】:Python Anaconda and azure-storage modulePython Anaconda 和 azure-storage 模块
【发布时间】:2017-03-27 18:28:45
【问题描述】:

我在 Azure 上使用安装了 anaconda python 的数据科学虚拟机。

我需要使用以下方式访问模块 Azure 存储 blob:

from azure.storage.blob import BlockBlobService

在处理这个命令时,我收到了模块azure.blob.storage 未找到的消息。我已经强制更新模块azure-storage:

pip install azure-storage --upgrade

缺少的模块出现在已安装的模块上,使用:

pip freeze

删除 Anaconda 并使用标准 Python 发行版后一切正常。

如何继续使用 Anaconda 并支持 azurestorage?有没有人尝试过这个问题并解决了它?

【问题讨论】:

  • 您需要确保使用与 Anaconda 安装相关的 pip 版本。 which pip的输出是什么

标签: python anaconda azure-storage azure-dsvm


【解决方案1】:

数据科学虚拟机的 Linux 风格包括两个 Anaconda 环境:root(使用 Python 2.7)和 py35(使用 Python 3.5)。你应该激活你想要的:

source activate py35

pippython 将同时引用同一个环境。

您可能需要以 root 身份运行 pip 来安装软件包。你可以这样做

sudo /anaconda/bin/pip

对于根环境,或

sudo /anaconda/envs/py35/bin/pip

适用于 py35 环境。

【讨论】:

    【解决方案2】:

    在 Azure VM for Data Science 上有两个 Python 安装,包括系统级别和 Anaconda 级别。

    正如@darthbith所说,当你运行命令which pip时,它会显示路径/usr/local/bin/pip,属于系统级别。

    你需要移动到Anaconda的路径bin,并使用当前Anaconda的./pip命令安装你想要的模块,如下使用jupyter终端。

    # For example, using anaconda for Python 2
    nbuser@nbserver:~$ cd anaconda2_20/bin
    # Using the Anaconda pip to install modules
    nbuser@nbserver:~/anaconda2_20/bin$ ./pip install azure-storage --upgrade
    # Then see the content below
    Collecting azure-storage                                                                                                                  
      Downloading azure_storage-0.33.0-py2-none-any.whl (182kB)                                                                               
        100% |################################| 184kB 2.9MB/s                                                                                 
    Collecting requests (from azure-storage)                                                                                                  
      Downloading requests-2.12.1-py2.py3-none-any.whl (574kB)                                                                                
        100% |################################| 583kB 1.7MB/s                                                                                 
    Requirement already up-to-date: azure-nspkg in /home/nbcommon/anaconda2_20/lib/python2.7/site-packages (from azure-storage)               
    Requirement already up-to-date: azure-common in /home/nbcommon/anaconda2_20/lib/python2.7/site-packages (from azure-storage)              
    Requirement already up-to-date: futures in /home/nbcommon/anaconda2_20/lib/python2.7/site-packages (from azure-storage)                   
    Collecting cryptography (from azure-storage)                                                                                              
      Downloading cryptography-1.5.3.tar.gz (400kB)
    .....
    

    然后为当前的 Anaconda 升级 azure-storgae 模块。

    希望对你有帮助。

    【讨论】:

      猜你喜欢
      • 2016-05-24
      • 1970-01-01
      • 2016-06-07
      • 2018-09-09
      • 1970-01-01
      • 1970-01-01
      • 2017-01-02
      • 2018-09-11
      • 2020-07-28
      相关资源
      最近更新 更多