How to determine Azure python sdk version? - python

I'm using notebooks.azure.com to learn python. I'm trying to manage Blobs with python sdk.
MUCH of the documentation I come across mentions pip install azure-storage-blob then using the BlobServiceClient (class?) to interact with Azure Storage.
UNFORTUNATELY, I get the error: ImportError: cannot import name 'BlobServiceClient' when trying to call from azure.storage import BlobServiceClient. This occurs after installing and upgrading azure-storage (v0.36.0) and azure-blob-storage (v12.3.0).
Here is a public Notebook showing the issue
Does this mean notebooks.azure.com is using the python v2.1 SDK (which appears to use BlockBlobService instead of BlobServiceClient)
How do I check which version of the python SDK my Azure Notebook is running?
EDIT 1:
No change after running !pip install azureml-sdk\[notebooks,automl\] --upgrade

Did you try
pip install --upgrade azureml-sdk\[notebooks,automl\]

azure-storage is deprecated, don't use that.

Related

Python import simple_salesforce in Databricks gives: No module named cryptography.hazmat.primitives.asymmetric.ed25519

I'm trying to use Azure Databricks to launch Python script that imports the library: "simple_salesforce"
I have installed the library as shown on the picture bellow, please note that while installing the library the name should be "simple-salesforce" and while importing it "simple_salesforce" (just to mention that I didn't mistaken the name):
Installation of the library
As shown on the picture bellow, the library was installed successfully:
simple-salesforce installed
When try to import it in my workspace, using:
import simple_salesforce
I get the following error (see the error picture bellow):
ImportError: No module named 'cryptography.hazmat.primitives.asymmetric.ed25519'
Error
I've tried to install the "cryptography" library with the same method I used to install the other libraries (see the picture bellow), but I still get the same error:
cryptography
Is there any step that I missed ?
Best regards,
You don't have the library "cryptography" installed. It is very likely that you are using a Databricks runtime version of 5.5 LTS or less, with one worker.
The problem is that you have a Databricks cluster with Python3 and the notebook is running on a Python2 kernel.
Method 1
Check if you have python 3:
%sh
python3 --version
Then install pip3:
%sh
sudo apt install python3-pip
After that you can install "cryptography"
Method 2
I highly recommand this method, which consists of using 7.4 Databricks Runtime version with a minimum of 2 workers, then you will have python3 and the library "cryptography" installed by default.
You will just need to install simple-salesforce manually from the libraries part, and:
import simple_salesforce

Google collab does not find Python package

I want to use sklearn_theano package in Google colab.
However, I simply do that :
import sklearn_theano
and get
ModuleNotFoundError: No module named 'sklearn_theano'
How to make the library available ??
Here's an example notebook demonstrating the install:
https://colab.research.google.com/drive/1gYny47qg3I3iiI-i5oMKuu4ZSsIzUiIJ
It mirrors the published installation instructions.
!pip install -q library
where library is what you want to install.

Cannot import name 'BlockBlobService'

I got the following error:
from azure.storage.blob import BlockBlobService
ImportError: cannot import name 'BlockBlobService'
when trying to run my python project using command prompt. (The code seems to work when i execute it directly from anaconda navigator.)
I am using Python 3.6.4 for Anaconda. Running pip freeze gives me the following:
azure-nspkg==2.0.0
azure-storage-blob==1.1.0
azure-storage-common==1.1.0
azure-storage-nspkg==3.0.0
azurepython3==1.7.7
There is no need to install the entire azure package.
I believe you are using the new azure-storage-blob library, but since BlockBlobService is from the old azure-storage library, to continue using it, you need to pip uninstall azure-storage-blob if you have installed the new library by accident, and then pip install azure-storage to install the old library.
If you would like to use the new library or cannot do the above, feel free to refer to my answer here which details the context and full instructions of using either the new azure-storage-blob library or the old azure-storage library.

trouble with importing gcloud libs in python script

I have updated gcloud components. I have installed BigQuery lib using pip install following the instructions in the online doc. I am running Python 2.7.10.
when I run a python script that has the following line:
from google.cloud import bigquery
it returns the following error:
ImportError: No module named google.cloud
I tried python 3.6 and still get the same error.
I did reintsall google sdk and still got the same error.
if I do touch /Library/Frameworks/Python.framework/Versions/2.7/lib/python‌​2.7/site-packages/go‌​ogle/init.py then import google woudl work, but not import google.cloud
any help is appreciated.
The Cloud SDK is not enough. Just use pip install --upgrade google-cloud-bigquery, see https://github.com/GoogleCloudPlatform/google-cloud-python/tree/master/bigquery

How to import Azure BlobService in python?

We are able to import azure.storage, but not access the BlobService attribute
The documentation says to use the following import statement:
from azure.storage import BlobService
But that get's the following error:
ImportError: cannot import name BlobService
We tried the following:
import azure.storage
...
foo = azure.storage.BlobService(...)
But that received the following error:
AttributeError: ‘module’ object has no attribute ‘BlobService’
We also tried all of the above with "azure.storage.blob" instead of "azure.storage"
We tried updating azure-storage package but it is up to date (version 0.30.0)
We also tried uninstalling azure-storage and installing the entire azure package, but we got the same results. We tried installing them with both pip and conda, but same results both times.
I am aware that the output suggests that this version of azure.storage has no BlobService attribute, but the documentation clearly states to import from there.
https://azure.microsoft.com/en-us/documentation/articles/machine-learning-data-science-create-features-blob/
If you want to use BlobService, you could install package azure.storage 0.20.0, there is BlobService in that version. In the latest azure.storage 0.30.0 , BlobSrvice is split into BlockBlobService, AppendBlobService, PageBlobService object, you could use BlockBlobService replace BlobService.
It's possible the library has changed since that tutorial was published, but...
I just tried this a few moments ago, successfully:
from azure.storage.blob import BlockBlobService
blob_service = BlockBlobService(account_name="...",account_key="...")
And I installed Azure storage locally via:
pip install azure-storage
I was able to test this by downloading an object from storage:
blob_service.get_blob_to_path("containername","blobname","localfilename")
Note: You could import PageBlobService in similar fashion, but you might not find that too valuable, since page blobs are primarily for vhd's.
I had the same issue after using pip to install the azure package and, as the chosen answer suggests, this can be fixed by installing azure.storage 0.33.0.
However, if you're using pip, you might need to use the "--upgrade" option for it to install properly (this was my experience):
pip install azure-storage --upgrade
I had version 1.0.3 installed (which includes azure.storage version 0.20) on Ubuntu server 16.04 LTS and pip only reinstalled version 0.20 of azure.storage when I uninstalled and reinstalled the azure package. This was according to the pypi page for the azure package v. 2.0.0rc6 which recommends that to upgrade from 1.0.3 to version 2 you should do
sudo pip3 uninstall azure
sudo pip3 install azure
pypi/azure
Instead, this worked for me,
sudo pip3 uninstall azure
sudo pip3 install azure==2.0.0rc6

Categories