Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing dependencies for a pip-only package through conda

Tags:

pip

conda

Sometimes I need to install a pip-only package into a conda environment. If I install the package using pip install, then all the dependencies for that package are installed using pip, even if they are available to conda.

I would like to install as many packages as possible through conda, so currently I use a hack to get the list of package dependencies through pip, search for all of them on conda, conda install the ones that are found, and then go through with the pip install.

Am I right to prefer installing dependencies through conda rather than pip? And if so, can anyone think of a more elegant way to solve this problem?

like image 649
mskel Avatar asked Dec 03 '16 06:12

mskel


People also ask

How do I install pip packages in conda?

You can install pip in the current conda environment with the command conda install pip , as discussed in Using pip in an environment. If there are instances of pip installed both inside and outside the current conda environment, the instance of pip installed inside the current conda environment is used.

Does conda install dependencies?

Conda provides many of the features found in pip, virtualenv, venv and pyenv. However it is a completely separate tool that will manage Python dependencies differently, and only works in Conda environments. Conda analyzes each package for compatible dependencies, and how to install them without conflict.

Can I use conda instead of pip?

Because Conda introduces a new packaging format, you cannot use pip and Conda interchangeably; pip cannot install the Conda package format. You can use the two tools side by side (by installing pip with conda install pip ) but they do not interoperate either.

Can you combine pip and conda?

Whilst conda can not install files from GitHub directly, we can use conda to install pip, and (via pip) access GitHub. Whilst over 1,500 packages are available in the Anaconda repository, this is tiny compared to the over 150,000 packages available on PyPI.


1 Answers

pip and conda are two separate package managers. Only in very rare cases package managers actually work together. In practical applications conda and pip usually do not.

In reality, mixing conda and pip packages is usually unavoidable. This often leads to a messy package management, as you describe.

In my opinion, the best and currently only proper way to solve this problem is to create a conda package for all (pypi-)packages and dependencies you want to use in your conda environments.

conda-forge is a community effort that offers an easy way to contribute your own package to the conda infrastructure. You may want to check out if your package is already available, and if not if contributing is an option for you.

like image 84
cel Avatar answered Sep 29 '22 06:09

cel