User Tools

Site Tools


conda_environment_file_to_install_different_packages_from_different_channels

conda environment file to install different packages from different channels

Background

yfinance library is the easiest and fastest way to download historical stock prices. Asof 2023-05-20, it is not available in the defaults channel. But it is available in the conda-forge channel.

Task

The goal here is to pull the yfinance package from conda-forge but everything else from the defaults channel.

Solution

 % cat env_test_yfinance.yml | stuff.py
name: test_yfinance
channels:
  - defaults
dependencies:
  - python=3.11
  - conda-forge::yfinance

where stuff.py is a python script to strip out the comments. It can be downloaded from https://github.com/KamarajuKusumanchi/rutils/blob/master/python3/stuff.py

Create the environment

 % conda env create -f ./env_test_yfinance.yml

Evidence

yfinance is downloaded from conda-forge.

 % conda list -n test_yfinance | grep conda-forge
multitasking              0.0.9              pyhd8ed1ab_0    conda-forge
yfinance                  0.2.18             pyhd8ed1ab_0    conda-forge

python is downloaded from the defaults channel

 % conda list -n test_yfinance | grep "python"     
python                    3.11.3               h7a1cb2a_0  
python-dateutil           2.8.2              pyhd3eb1b0_0

See also

conda_environment_file_to_install_different_packages_from_different_channels.txt · Last modified: 2023/07/28 22:32 by raju