astron-cats
astron-cats

Reputation: 41

create conda env with specific python version, with that python package predownloaded

I’m trying to create a Conda env with a specific python version, e.g.,

conda create --name my_env python=3.6

which gives:

Collecting package metadata (current_repodata.json): done
Solving environment: done

## Package Plan ##

  environment location: /Users/*/anaconda3/envs/my_env

  added / updated specs:
    - python=3.6


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    python-3.6.12              |       h26836e1_2        16.9 MB
    ------------------------------------------------------------
                                           Total:        16.9 MB

The following NEW packages will be INSTALLED:

  ca-certificates    pkgs/main/osx-64::ca-certificates-2020.7.22-0
  certifi            pkgs/main/osx-64::certifi-2020.6.20-py36_0
  libcxx             pkgs/main/osx-64::libcxx-10.0.0-1
  libedit            pkgs/main/osx-64::libedit-3.1.20191231-h1de35cc_1
  libffi             pkgs/main/osx-64::libffi-3.3-hb1e8313_2
  ncurses            pkgs/main/osx-64::ncurses-6.2-h0a44026_1
  openssl            pkgs/main/osx-64::openssl-1.1.1g-h1de35cc_0
  pip                pkgs/main/osx-64::pip-20.2.2-py36_0
  python             pkgs/main/osx-64::python-3.6.12-h26836e1_2
  readline           pkgs/main/osx-64::readline-8.0-h1de35cc_0
  setuptools         pkgs/main/osx-64::setuptools-49.6.0-py36_0
  sqlite             pkgs/main/osx-64::sqlite-3.33.0-hffcf06c_0
  tk                 pkgs/main/osx-64::tk-8.6.10-hb0a8c7a_0
  wheel              pkgs/main/noarch::wheel-0.35.1-py_0
  xz                 pkgs/main/osx-64::xz-5.2.5-h1de35cc_0
  zlib               pkgs/main/osx-64::zlib-1.2.11-h1de35cc_3

But since I continue getting this error when it's trying to download the python package:

Downloading and Extracting Packages
python-3.6.12        | 16.9 MB   | ###################################################################################6                             |  75% 

CondaError: Downloaded bytes did not match Content-Length
  url: https://repo.anaconda.com/pkgs/main/osx-64/python-3.6.12-h26836e1_2.conda
  target_path: /Users/*/anaconda3/pkgs/python-3.6.12-h26836e1_2.conda
  Content-Length: 17674328
  downloaded bytes: 13207996

I decided to download the python package first via curl:

curl https://repo.anaconda.com/pkgs/main/osx-64/python-3.6.12-h26836e1_2.conda --output /Users/*/anaconda3/pkgs/python-3.6.12-h26836e1_2.conda

However, when I run the create env command again, I see that it is trying the download the package package again... Is there a way to tell conda to install from the package that I already downloaded instead of downloading it again? Thanks in advance!!!

Upvotes: 4

Views: 11129

Answers (1)

Simba
Simba

Reputation: 27588

The downloading failed. The package was not downloaded completely and broken.

Cleanup the package cache and reinstall python 3.6.

conda clean --tarballs

# if my_env is not created
conda create --name my_env python=3.6

# else if my_env has been created already
conda activate my_env
conda install python=3.6 -y

Don't try to download the python package manually. Cause

  1. python depends on other packages (about 14 other pkgs), you have to walk the dependency tree and download every dependents one by one.
  2. Only put the python pkg into conda cache is not enough. Additional info is written after unpacking the .conda file.

Upvotes: 4

Related Questions