How to install from specific url with conda env file (yml)

Viewed 170

Anyone out there knows how to install a conda package (not pip) from a specific url with a conda env file (yml)?

Example: :

name: special_env

channels:
  - defaults

dependencies:
  - python=3.8
  - pip=21.2.4
  - https://special_place.com/special/special_conda_pack.tar-01.2.03-0.bz2 <--- I want something like that.

(https://special_place.com/special/special_conda_pack-01.2.03-0.tar.bz2 is only use as example this is not my real url)

I tried something similar to https://stackoverflow.com/a/54084615/6210975 and many other attempts by playing with channels without success.

NOTE1: I am able to install my package with conda install https://special_place.com/special/special_conda_pack-01.2.03-0.tar.bz2

NOTE2 Also tried this approach:

Since conda install https://special_place.com/special/special_conda_pack.tar.bz2 is working. I I thought I could simply create a test env and then export it with conda env export > env_with_resolved_url.yml

name: env_with_resolved_url
channels:
  - https://special_place.com/special/...       <--- Resolved url

dependencies:
  - ...
  - special_conda_pack=01.2.03=0                <--- Resolved versioning format
  - ...

prefix: /.../miniconda3/envs/env_with_resolved_url

However when I try to recreate this env from file I get UnavailableInvalidChannel: The channel is not accessible or is invalid. (error code: 404)

1 Answers

This ain't my prefered option but it does the trick. Basically I create a custom channel with the manually downloaded package (see https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/create-custom-channels.html for more details) and then I use it in my env file (yml) or my config file (.condarc):

channels:
  - ...
  - file:///path_to_custom_local_channel_using_downloaded_bz2
  - ...

In your env file (.yml) don't forget to use versioning properly. For example for special_conda_pack.tar-01.2.03-0.bz2 you need to use:

dependencies:
  - ...
  - special_conda_pack=01.2.03=0                <--- Resolved versioning format
  - ...
Related