2

I am trying to run this tutorial

https://learn.microsoft.com/en-US/azure/data-factory/quickstart-create-data-factory-python

but I fail to install the packages. I tried several installations but I keep getting the error No module named 'azure.mgmt.datafactory' when trying to run from azure.mgmt.datafactory import DataFactoryManagementClient.

I am using anaconda and windows 10.

I tried running the recommended anaconda packages https://anaconda.org/anaconda/azure and https://anaconda.org/clinicalgraphics/azure-mgmt-resource under a python 3.5 environment and I also tried to manually install everything from github (https://github.com/Azure/azure-sdk-for-python) using

git clone git://github.com/Azure/azure-sdk-for-python.git 
cd azure-sdk-for-python 
python setup.py install

In both the normal (Python 3.6) and the new (Python 3.5, using Anaconda version with Python 3.5) environment. None of this worked.

What am I missing?

(Note that from azure.mgmt.resource import ResourceManagementClient worked fine with the anaconda installation)

EDIT

After the first response, I ran the following commands from the powershell

 pip install azure-mgmt-resource
 pip install azure-mgmt-datafactory
 pip install azure-mgmt

which resulted in ModuleNotFoundError: No module named 'azure.mgmt'

Uninstalling the three packages and installing azure-mgmt as a first one did not solve the issue either. However, I don't know how to uninstall the manually installed package from python setup.py install, which still might be an issue.

Eulenfuchswiesel
  • 879
  • 9
  • 20

2 Answers2

2

Have you tried pip install in powershell/cmd?

pip install azure-mgmt-datafactory

Update (Jan's answer):

pip freeze > requirements.txt
pip uninstall -r requirements.txt
python -m pip install azure-common
python -m pip install azure-mgmt
python -m pip install azure-mgmt-datafactory (this might not be needed as it comes with azure-mgmt)
dim_user
  • 969
  • 1
  • 13
  • 24
  • I seem to remember a time when pip did not work in anaconda. The installation worked, but now it says `No module named 'azure.mgmt'` - I'll try to uninstall everything and give it another shot. – Eulenfuchswiesel Jan 30 '18 at 15:44
  • Sorry, uninstalling everything (as good as possible) and running the pip commands (also `pip install azure-mgmt-resource`) under powershell resultet in the same error. No module named `azure.mgmt` – Eulenfuchswiesel Jan 30 '18 at 16:02
  • seems like a different problem, do you have multiple python interpreters installed? check this out: https://stackoverflow.com/questions/32680081/importerror-after-successful-pip-installation you may want to python -m pip install installs it in the default interpreter run this which -a python and see how many you have, the first one should be the one that runs from powershell. – dim_user Jan 30 '18 at 16:24
  • just to be on the same page, you pip uninstalled both azure-mgmt-datafactory and azure-mgmt and did pip install azure-mgmt again? just do a pip install azure-mgmt as recommended https://pypi.python.org/pypi/azure-mgmt and not azure-mgmt-resource – dim_user Jan 30 '18 at 16:42
  • OK, I got `azure.mgmt.datafacory` briefly to work, but then `azure.common.credentials` could not be found any more. Now, after uninstalling and reinstalling `azure.mgmt.datafactory`, `azure.common.credentials` returned but now the datafactory is missing again. – Eulenfuchswiesel Jan 31 '18 at 10:13
  • Hmm interesting, where are you running your python code? Your imports, etc. Which editor are you using? Pycharm, spyder? – dim_user Jan 31 '18 at 13:26
  • I run my code in iPython, which might be an outdated way of working but does the job for me. – Eulenfuchswiesel Jan 31 '18 at 15:50
1

Ok, this is how I got the required azure libraries to work (thx to Saul Cruy, who gave me the idea)

Using this post What is the easiest way to remove all packages installed by pip?, I created a requirements file in PowerShell

pip freeze > requirements.txt

In this file, I manually kept only the entries with azure. Then, I deleted all packages in the file

pip uninstall -r requirements.txt

The steps above were repeated twice, as upon first delete, some azure packages survived.

Then, I ran (all in PowerShell, in that order)

python -m pip install azure-common
python -m pip install azure-mgmt
python -m pip install azure-mgmt-datafactory

The reason might(!) be that installing packages in the anaconda console using the conda commands causes confusion in the dependencies (I tried a similar approach in a conda environment as it seemed like a good idea to seperate the azure packages from the other ones, but without success).

Eulenfuchswiesel
  • 879
  • 9
  • 20