pythonazure-data-explorer

Unable to import azure.kusto.ingest


I’m trying to import azure.kusto.ingest in my Python script, but I’m getting an ImportError stating that the module cannot be found.

I’ve already installed the required package using:

pip install azure-kusto-ingest

To confirm that the package is installed, I ran:

pip show azure-kusto-ingest

And it correctly displays the package details. However, when I try to import it I get the below error

enter image description here

enter image description here


Solution

  • It correctly displays the package details. However, when I try to import it, I get the below error: -

    Good that the issue got resolved from the comments. For benefit of the community, here I provided the detailed solution.

    Though you installed a package in your environment to deal with Kusto python SDK libraries, it might be possible that the conflict occurs with imports or package installations.

    Firstly, check the Python environment where the package is installed and also check if the versions are compatible. I would suggest you activate a virtual environment to execute python scripts and install their dependencies.

    To do from the terminal, use below given commands.

    py -m venv .venv
    .venv\Scripts\activate
    

    Once activated, now install azure-kusto-ingest package inside the virtual environment with below command.

    pip install azure-kusto-ingest

    Also check the interpreter path when you are running the script. Usually, visual studio code allows us to choose the Python interpreter path when you execute. Make sure that the relevant interpreter with latest version is selected, as there could be different interpreters may have different sets of installed modules.

    enter image description here

    After activating the virtual environment, also you can provide pip install -r requirements.txt command for successfully installing the modules present in requirements file.

    You can also verify where pip installs the package with command python -m site. It provides you all the sys path details of python libraries as shown below.

    enter image description here

    As you already tried to show the package with pip show command, instead try python -m pip show azure-kusto-ingest to exactly show the package which makes sure that you are using the same Python environment without any conflict.

    If none of the above resolves your issue, try uninstalling the existed Kusto package as well as pip and reinstall all the libraries to execute it without any fail.