python console - one instance does not recognise packages

74 views Asked by At

I have been working on adding AWS data into Power BI using Python. I have the script that ingests it and it is working. My problem is that Power BI gives me an error. I troubleshoot the error and found something I reckon is the source of it. Just need some help to understand it and fix it.

I have a conda env 'poc' and when I run the Python from Anaconda Navigator everything works. I checked where that Python.exe instance is stored. When I run the Python.exe from that folder it does not work.

Here is the code in the Python console when run from the Anaconda Navigator:

Python 3.8.5 (default, Sep  3 2020, 21:29:08) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.

    import pandas
    import os
    import sys
            
    os.path.dirname(sys.executable)
    'C:\\ProgramData\\Anaconda3\\envs\\poc'

Now I go to the specified directory and run the Python.exe and it gives me the error that the env is not activated and it is.

    Python 3.8.5 (default, Sep  3 2020, 21:29:08) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32

    Warning:
    This Python interpreter is in a conda environment, but the environment has
    not been activated.  Libraries may fail to load.  To activate this environment
    please see https://conda.io/activation

I also tested the whole approach by installing winPython and it worked (I got AWS data into Power BI).

My question is, how can I use conda env 'poc' or what I am doing wrong when trying to use Anaconda and my 'poc' env?

1

There are 1 answers

1
deltastar On

That's because you need to activate the conda env in the anaconda cmd, and then run it from there.