Search code examples
pythonminiconda

Using Minconda creates new Python install


Was trying to resolve a HDF5 mismatch error by uninstalling the parent package yt ie

  PIP uninstall yt

and then reinstalling using Miniconda

  conda install yt

If I simply open a terminal and do an import yt

no problem! However, from with my application when I open a Python shell and do an import yt I get an error

'ImportError: No module named yt'

So I think the error is either my application does not know the path to yt, or When I installed Miniconda it installed its own version of Python. How can I resolve this?


Solution

  • Conda always creates a python virtual environment and so it installs packages into this environment. Thus your installation lives only inside of this environment.

    If you want to use the packages conda installed, then you have to use conda's bash shell, or use some other tools inside of conda within the given environment.

    If you have a python code, what you want to run with yt - importing it, then you have to run it inside of the conda environment where you installed yt.

    You can do it e.g. with starting anaconda-navigator, choose Environments, click on the green solid arrow and choose any options to run your application.

    Alternatively you can directly activate conda's virtualenv via:

    On Windows, in your Anaconda Prompt, run:

    activate myenv
    

    On macOS and Linux, in your Terminal Window, run:

    source activate myenv
    

    Then you can start your application in this environment as normal.

    UPDATE:

    According to darthbith, since conda 4.4, the command is

    conda activate myenv 
    

    on all platforms.