Conda get path of package installation

Viewed 5069

I'd like to find out where yaml package has been installed as Python is unable to import it after installation.

I've a conda environment in my project directory, and in the Conda install command I've also specifically specified the environment despite it already being activated:

$ conda list | grep yaml
yaml                      0.1.7
$ conda install yaml --prefix /home/abc/project_dir/envs/
Collecting package metadata (current_repodata.json): done
Solving environment: done

# All requested packages already installed.

Am unable to find yaml though:

$ find /home/abc/project_dir/envs/ -name yaml 
(envs)$

Checking sys.path shows python is only looking in the envs path, and since yaml isn't present, the import is failing.

>>> print(sys.path)
['', 'home/abc/project_dir/envs/lib/python37.zip', 'home/abc/project_dir/envs/lib/python3.7', 'home/abc/project_dir/envs/lib/python3.7/lib-dynload', 'home/abc/project_dir/envs/lib/python3.7/site-packages']

I've already tried to uninstall and install it again. At this point I'd just like to understand where it's actually installed so that I can add it manually to the path.

2 Answers

I was looking for the path of Python within Conda. I used

conda info --all | grep -i python

In my application I got a few matches:

sys.executable: /opt/anaconda/anaconda3/bin/python  
conda location: /opt/anaconda/anaconda3/lib/python3.8/site-packages/conda  
CONDA_PYTHON_EXE: /opt/anaconda/anaconda3/bin/python 

The environment variable CONDA_PYTHON_EXE is typical of Linux; sys.executable of Python. Windows and/or non-Python users may find comparable information in this way

I was specifying yaml, whereas I should have been installing pyyaml:

conda install pyyaml

Related