conda 离线安装某个包(不能识别离线安装的包问题)

conda 离线安装某个包(不能识别离线安装的包问题)

  • conda 离线安装某个包(不能识别离线安装的包问题)

conda 离线安装某个包(不能识别离线安装的包问题)

用conda 安装包时,有时候会出现某个依赖包过大下载失败的问题(清华源),这个时候通过 --offline或者use-local参数指定下载好的conda包或者tar.bz包,之后再运行conda install 包名 会识别已安装的离线依赖包为低版本(unknown), 会重新下载安装,下面介绍完整安装过程
在这里插入图片描述
以python3.7为例

$ conda install python=3.7
Collecting package metadata (current_repodata.json): done
Solving environment: done

## Package Plan ##

  environment location: /home/gotpl/miniconda3/envs/pytorch

  added / updated specs:
    - python=3.7


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    python-3.7.9               |       h7579374_0        45.3 MB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    ------------------------------------------------------------
                                           Total:        45.3 MB

The following NEW packages will be INSTALLED:

  _libgcc_mutex      anaconda/pkgs/main/linux-64::_libgcc_mutex-0.1-main
  ca-certificates    anaconda/pkgs/main/linux-64::ca-certificates-2020.10.14-0
  certifi            anaconda/pkgs/main/linux-64::certifi-2020.11.8-py37h06a4308_0
  ld_impl_linux-64   anaconda/pkgs/main/linux-64::ld_impl_linux-64-2.33.1-h53a641e_7
  libedit            anaconda/pkgs/main/linux-64::libedit-3.1.20191231-h14c3975_1
  libffi             anaconda/pkgs/main/linux-64::libffi-3.3-he6710b0_2
  libgcc-ng          anaconda/pkgs/main/linux-64::libgcc-ng-9.1.0-hdf63c60_0
  libstdcxx-ng       anaconda/pkgs/main/linux-64::libstdcxx-ng-9.1.0-hdf63c60_0
  ncurses            anaconda/pkgs/main/linux-64::ncurses-6.2-he6710b0_1
  openssl            anaconda/pkgs/main/linux-64::openssl-1.1.1h-h7b6447c_0
  pip                anaconda/pkgs/main/linux-64::pip-20.3-py37h06a4308_0
  python             anaconda/pkgs/main/linux-64::python-3.7.9-h7579374_0
  readline           anaconda/pkgs/main/linux-64::readline-8.0-h7b6447c_0
  setuptools         anaconda/pkgs/main/linux-64::setuptools-50.3.2-py37h06a4308_2
  sqlite             anaconda/pkgs/main/linux-64::sqlite-3.33.0-h62c20be_0
  tk                 anaconda/pkgs/main/linux-64::tk-8.6.10-hbc83047_0
  wheel              anaconda/pkgs/main/noarch::wheel-0.35.1-pyhd3eb1b0_0
  xz                 anaconda/pkgs/main/linux-64::xz-5.2.5-h7b6447c_0
  zlib               anaconda/pkgs/main/linux-64::zlib-1.2.11-h7b6447c_3


Proceed ([y]/n)? ^C
CondaSystemExit:
Operation aborted.  Exiting.

直接Ctrl+C中断,然后执行以下命令获取依赖包下载地址,通过浏览器或下载器下载,目录自己指定

(pytorch)
# gotpl @ DESKTOP-OD6NCUQ in ~/temp [10:45:51]
$ conda search python=3.7.9 --info
Loading channels: done
python 3.7.9 h7579374_0
-----------------------
file name   : python-3.7.9-h7579374_0.conda
name        : python
version     : 3.7.9
build       : h7579374_0
build number: 0
size        : 45.3 MB
license     : PSF
subdir      : linux-64
url         : https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64/python-3.7.9-h7579374_0.conda
md5         : e8871e5a420f47397833fd2f3f0dac7a
timestamp   : 2020-08-31 12:50:58 UTC
dependencies:
  - ld_impl_linux-64
  - libffi >=3.3,<3.4.0a0
  - libgcc-ng >=7.3.0
  - ncurses >=6.2,<7.0a0
  - openssl >=1.1.1g,<1.1.2a
  - readline >=8.0,<9.0a0
  - sqlite >=3.33.0,<4.0a0
  - tk >=8.6.10,<8.7.0a0
  - xz >=5.2.5,<6.0a0
  - zlib >=1.2.11,<1.3.0a0
  - pip


python 3.7.9 h7579374_0
-----------------------
file name   : python-3.7.9-h7579374_0.conda
name        : python
version     : 3.7.9
build       : h7579374_0
build number: 0
size        : 45.3 MB
license     : PSF
subdir      : linux-64
url         : https://repo.anaconda.com/pkgs/main/linux-64/python-3.7.9-h7579374_0.conda
md5         : e8871e5a420f47397833fd2f3f0dac7a
timestamp   : 2020-08-31 12:50:58 UTC
dependencies:
  - ld_impl_linux-64
  - libffi >=3.3,<3.4.0a0
  - libgcc-ng >=7.3.0
  - ncurses >=6.2,<7.0a0
  - openssl >=1.1.1g,<1.1.2a
  - readline >=8.0,<9.0a0
  - sqlite >=3.33.0,<4.0a0
  - tk >=8.6.10,<8.7.0a0
  - xz >=5.2.5,<6.0a0
  - zlib >=1.2.11,<1.3.0a0
  - pip

直接使用第一个url(以防万一可以对比conda install安装输出的包信息): https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64/python-3.7.9-h7579374_0.conda
我这里放到了~/temp目录下, 下面使用use-local离线安装

(pytorch)
# gotpl @ DESKTOP-OD6NCUQ in ~/temp [10:47:01]
$ conda install --use-local ~/temp/python-3.7.9-h7579374_0.conda

Downloading and Extracting Packages
############################################################################################################################# | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
(pytorch)
# gotpl @ DESKTOP-OD6NCUQ in ~/temp [10:47:37]
$ conda install python=3.7
Collecting package metadata (current_repodata.json): done
Solving environment: -
The environment is inconsistent, please check the package plan carefully
The following packages are causing the inconsistency:

  - <unknown>/linux-64::python==3.7.9=h7579374_0
done

## Package Plan ##

  environment location: /home/gotpl/miniconda3/envs/pytorch

  added / updated specs:
    - python=3.7


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    python-3.7.9               |       h7579374_0        45.3 MB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    ------------------------------------------------------------
                                           Total:        45.3 MB

The following NEW packages will be INSTALLED:

  _libgcc_mutex      anaconda/pkgs/main/linux-64::_libgcc_mutex-0.1-main
  ca-certificates    anaconda/pkgs/main/linux-64::ca-certificates-2020.10.14-0
  certifi            anaconda/pkgs/main/linux-64::certifi-2020.11.8-py37h06a4308_0
  ld_impl_linux-64   anaconda/pkgs/main/linux-64::ld_impl_linux-64-2.33.1-h53a641e_7
  libedit            anaconda/pkgs/main/linux-64::libedit-3.1.20191231-h14c3975_1
  libffi             anaconda/pkgs/main/linux-64::libffi-3.3-he6710b0_2
  libgcc-ng          anaconda/pkgs/main/linux-64::libgcc-ng-9.1.0-hdf63c60_0
  libstdcxx-ng       anaconda/pkgs/main/linux-64::libstdcxx-ng-9.1.0-hdf63c60_0
  ncurses            anaconda/pkgs/main/linux-64::ncurses-6.2-he6710b0_1
  openssl            anaconda/pkgs/main/linux-64::openssl-1.1.1h-h7b6447c_0
  pip                anaconda/pkgs/main/linux-64::pip-20.3-py37h06a4308_0
  readline           anaconda/pkgs/main/linux-64::readline-8.0-h7b6447c_0
  setuptools         anaconda/pkgs/main/linux-64::setuptools-50.3.2-py37h06a4308_2
  sqlite             anaconda/pkgs/main/linux-64::sqlite-3.33.0-h62c20be_0
  tk                 anaconda/pkgs/main/linux-64::tk-8.6.10-hbc83047_0
  wheel              anaconda/pkgs/main/noarch::wheel-0.35.1-pyhd3eb1b0_0
  xz                 anaconda/pkgs/main/linux-64::xz-5.2.5-h7b6447c_0
  zlib               anaconda/pkgs/main/linux-64::zlib-1.2.11-h7b6447c_3

The following packages will be SUPERSEDED by a higher-priority channel:

  python                                          <unknown> --> anaconda/pkgs/main


Proceed ([y]/n)? ^C
CondaSystemExit:
Operation aborted.  Exiting.

这里再次执行安装命令发现无法识别自己下载安装的包,这时候需要更改包的channel标记信息,需要更改的文件位置,具体路径看自己conda安装位置

$ vim ~/miniconda3/envs/pytorch/conda-meta/python-3.7.9-h7579374_0.json

conda 离线安装某个包(不能识别离线安装的包问题)_第1张图片
更改unknown为: https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64
conda 离线安装某个包(不能识别离线安装的包问题)_第2张图片
保存,再次执行conda install 安装

$ conda install python=3.7
Collecting package metadata (current_repodata.json): done
Solving environment: |
The environment is inconsistent, please check the package plan carefully
The following packages are causing the inconsistency:

  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64::python==3.7.9=h7579374_0
done

## Package Plan ##

  environment location: /home/gotpl/miniconda3/envs/pytorch

  added / updated specs:
    - python=3.7


The following NEW packages will be INSTALLED:

  _libgcc_mutex      anaconda/pkgs/main/linux-64::_libgcc_mutex-0.1-main
  ca-certificates    anaconda/pkgs/main/linux-64::ca-certificates-2020.10.14-0
  ld_impl_linux-64   anaconda/pkgs/main/linux-64::ld_impl_linux-64-2.33.1-h53a641e_7
  libedit            anaconda/pkgs/main/linux-64::libedit-3.1.20191231-h14c3975_1
  libffi             anaconda/pkgs/main/linux-64::libffi-3.3-he6710b0_2
  libgcc-ng          anaconda/pkgs/main/linux-64::libgcc-ng-9.1.0-hdf63c60_0
  libstdcxx-ng       anaconda/pkgs/main/linux-64::libstdcxx-ng-9.1.0-hdf63c60_0
  ncurses            anaconda/pkgs/main/linux-64::ncurses-6.2-he6710b0_1
  openssl            anaconda/pkgs/main/linux-64::openssl-1.1.1h-h7b6447c_0
  readline           anaconda/pkgs/main/linux-64::readline-8.0-h7b6447c_0
  sqlite             anaconda/pkgs/main/linux-64::sqlite-3.33.0-h62c20be_0
  tk                 anaconda/pkgs/main/linux-64::tk-8.6.10-hbc83047_0
  xz                 anaconda/pkgs/main/linux-64::xz-5.2.5-h7b6447c_0
  zlib               anaconda/pkgs/main/linux-64::zlib-1.2.11-h7b6447c_3


Proceed ([y]/n)?

Preparing transaction: done
Verifying transaction: done
Executing transaction: done

你可能感兴趣的:(笔记,anaconda,python,pip,深度学习)