pythonazurevisual-studio-codeazure-devopsazureml-python-sdk

unable to import azureml in vscode


I've installed python 3.8, from vscode terminal I created an env and seem to have successfully installed azureml as below:

C:\Python38\python.exe -m venv tempml
tempml\scripts\activate
pip install azureml-core

I then go into python and type

import azureml

but I get the following error: ModuleNotFoundError: No module named 'azureml'

if i go back to terminal and type

pip show azureml-core

i can indeed see it:

Name: azureml-core
Version: 1.53.0
Summary: Azure Machine Learning core packages, modules, and classes
Home-page: https://docs.microsoft.com/python/api/overview/azure/ml/?view=azure-ml-py
Author: Microsoft Corp
Author-email: None
License: https://aka.ms/azureml-sdk-license
Location: c:\python38\tempml\lib\site-packages
Requires: docker, msal, azure-common, paramiko, msrestazure, azure-mgmt-resource, msrest, PyJWT, azure-graphrbac, azure-core, ndg-httpsclient, contextlib2, jmespath, backports.tempfile, adal, argcomplete, urllib3, azure-mgmt-network, cryptography, knack, pkginfo, python-dateutil, jsonpickle, azure-mgmt-keyvault, azure-mgmt-containerregistry, azure-mgmt-storage, humanfriendly, azure-mgmt-authorization, pathspec, pytz, msal-extensions, requests, pyopenssl, packaging, SecretStorage
Required-by:

if someone could please help it would be much appreciated. Thank you


Solution

  • I found the absolute path and then added it using sys:

    pip show azureml-core
    

    then in python:

    import sys
    sys.path.append("c:/python38/tempml/lib/site-packages/")
    

    and this now works