1

I am trying to download a file from Azure onto my local device via python using the following code:

from azure.storage.blob import BlockBlobService
block_blob_service = BlockBlobService(account_name='account_name', 
account_key='mykey')
block_blob_service.get_blob_to_path('container', 'file', 'out-test.csv')

However, when I run this code I get the following error:

ImportError: No module named azure.storage.blob

I already have installed the azure modules as seen by the snipping of the output of pip list:

C:\Users\hpfc87>pip list
Package              Version
-------------------- ---------
adal                 0.6.0
asn1crypto           0.24.0
azure-common         1.1.11
azure-nspkg          2.0.0
azure-storage        0.36.0
azure-storage-blob   1.1.0
azure-storage-common 1.1.0
azure-storage-file   1.1.0
azure-storage-nspkg  3.0.0
azure-storage-queue  1.1.0

I have tried following various posts about this issue like the following, but I have had no luck:

ImportError: No module named azure.storage.blob (when doing syncdb)

https://github.com/Azure/azure-storage-python/issues/262

Any advice?

ElecHertz
  • 13
  • 1
  • 3
  • Do you have more than one Python installation? If so, are you sure that the one you're using to run the script is the same as the one you're using to `pip list`? – abarnert May 22 '18 at 21:42
  • I only have python 2.7 – ElecHertz May 22 '18 at 21:54
  • Can you try this? `from azure.storage.blob.blockblobservice import *` ? – Saher Ahwal May 22 '18 at 22:26
  • also make sure if you installed 64-bit version of new python lib you also are running python 64-bit and vice versa with 32-bit. – Saher Ahwal May 22 '18 at 22:29
  • My bad, I just realized I might have two versions of python installed. I first installed python 2.7 and then installed anaconda to get spyder and jupyter. Might this cause two versions to be installed? I have been using spyder through anaconda and getting the above errors. As soon as I tried using the command line to run the script instead of spyder, it ran with no errors. – ElecHertz May 22 '18 at 22:55

1 Answers1

0

Just for summary, your issue is resulted from the conflict between python 2.7 version you installed and the python version with Anaconda.

The packages you installed should to be in the python 2.7 environment. However, spyder uses the Anaconda self-brought python environment.

Command line uses system python environment which is determined by the the previous python environment variable in the path.

Jay Gong
  • 23,163
  • 2
  • 27
  • 32