2

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.

AMC
  • 2,642
  • 7
  • 13
  • 35
Maikol
  • 195
  • 2
  • 2
  • 10
  • 3
    `yaml` is a c library, did you mean to install the python library `pyyaml`? – cel Jun 25 '20 at 19:47
  • Also, you can see which files belong to a conda package by inspecting the package metadata in the `pkgs` directory. Try this: `cat $(conda info --base)/pkgs/yaml-0.1.7-*/info/files`. That will show you that the `yaml` package does not contain python files, only compiled `.so` binary files. – Stuart Berg Jun 27 '20 at 18:51
  • Yes, silly me! You guys are right, I was installing the wrong package. – Maikol Jun 27 '20 at 18:52

2 Answers2

1

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

XavierStuvw
  • 1,294
  • 2
  • 15
  • 30
0

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

conda install pyyaml

Maikol
  • 195
  • 2
  • 2
  • 10