Is there a way to create a file that both pip and conda could install from?
No, not generally. This is because Conda additionally manages non-Python dependencies (e.g., dynamic libraries compiled from other languages), which are things that typically are not provided by PyPI. So, even though Conda can output a Pip-like requirements.txt
(i.e., with conda list --export
), some of the packages are specific to Conda.
As for installing GitHub projects into Conda envs, anything one can do with Pip can be accomplished in a YAML file, e.g., working from the referenced question:
YAML
name: my_env
channels:
- defaults
dependencies:
- pip
- pip:
- -e git://github.com/mozilla/elasticutils.git#egg=elasticutils
would install a GitHub-hosted package using Pip. See the Advanced Pip Example in the Conda repository, for additional examples.
Using a Pip Requirements File in Conda
One can also use a Pip requirements.txt
indirectly in Conda by creating a YAML wrapper for it. For example,
requirements.txt
-e git://github.com/mozilla/elasticutils.git#egg=elasticutils
my_env.yaml
name: my_env
channels:
- defaults
dependencies:
- pip
- pip:
- -r requirements.txt
which you can use either to create a new env:
conda env create -f my_env.yaml
or to update an existing env:
conda env update -f my_env.yaml
and it will use Pip to install from GitHub.