Reputation: 4583
I am using both pip
and conda
to install dependencies for my project. I keep dependencies that I wish to install via conda
in an environment.yml
file and dependencies which I install via pip
inside a requirements.txt
file (which I reference from inside the environment.yml
file). Here is the repo with the actual config files for reference.
From the install logs it appears that conda
first runs the command
$ conda env create --prefix ./env --file environment.yml
and the runs the pip install
command as a sub-process. However I don't understand from the logs whether or not the environment has been temporarily activated before the pip
command is run.
I can explicitly force the desired behavior by running the following commands (after removing the reference to the requirements.txt
file inside the environment.yml
file)
$ conda env create --prefix ./env --file environment.yml
$ conda activate ./env
$ pip install -r requirements.txt
But I would like to know if this is what already happens "under the hood".
Upvotes: 0
Views: 453
Reputation: 601
In the environment.yml file itself you can menton the pip packages as well.You don't need to create a seperate requirements.txt file for pip packages.
Usually an environment.yml file contains the following fields:
name : the conda environment name
channels: the channels from which the dependencies needs to be installed
dependencie:: list of package. In that you can mention the pip dependencies as well
For more details, you can refer the following urls:
The pip dependencies will be installed in the conda environment and you don't need to activate the environment and install pip dependencies manually. Command to create conda environment:
conda env create -f environment.yml
Once the above command completes successfully, you can activate the environment and check the installed packages as below:
conda activate <env_name>
conda list
Upvotes: 1