conda install 出錯


在下載包時出現下面的錯誤:

userdeMBP:pytorch user$ conda install -n deeplearning matplotlib
Solving environment: failed

CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://repo.anaconda.com/pkgs/main/osx-64/repodata.json.bz2>
Elapsed: -

An HTTP error occurred when trying to retrieve this URL.
HTTP errors are often intermittent, and a simple retry will get you on your way.

If your current network has https://www.anaconda.com blocked, please file
a support request with your network engineering team.

ConnectionError(MaxRetryError('HTTPSConnectionPool(host=\'repo.anaconda.com\', port=443): Max retries exceeded with url: /pkgs/main/osx-64/repodata.json.bz2 (Caused by ReadTimeoutError("HTTPSConnectionPool(host=\'repo.anaconda.com\', port=443): Read timed out. (read timeout=9.15)"))'))

一開始是調用config命令去設置清華的鏡像:

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/c conda config --set show_channel_urls yes //設置配置中的參數 conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/ conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/

但是還是出錯:

(deeplearning) userdeMBP:~ user$ conda install matplotlib
Solving environment: failed

CondaHTTPError: HTTP 404 NOT FOUND for url <https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/c/noarch/repodata.json>
Elapsed: 00:00.226091

The remote server could not find the noarch directory for the
requested channel with url: https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/c

As of conda 4.3, a valid channel must contain a `noarch/repodata.json` and
associated `noarch/repodata.json.bz2` file, even if `noarch/repodata.json` is
empty. please request that the channel administrator create
`noarch/repodata.json` and associated `noarch/repodata.json.bz2` files.
$ mkdir noarch
$ echo '{}' > noarch/repodata.json
$ bzip2 -k noarch/repodata.json

You will need to adjust your conda configuration to proceed.
Use `conda config --show channels` to view your configuration's current state.
Further configuration help can be found at <https://conda.io/docs/config.html>.

后面發現可能是這個鏡像的問題,打開本地的.condrac文件,將設置的channels改成:

- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/

后面再運行就發現成功了

 

(deeplearning) userdeMBP:~ user$ conda install matplotlib
Solving environment: done


==> WARNING: A newer version of conda exists. <==
  current version: 4.5.12
  latest version: 4.6.8

Please update conda by running

    $ conda update -n base -c defaults conda



## Package Plan ##

  environment location: /anaconda3/envs/deeplearning

  added / updated specs: 
    - matplotlib


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    tornado-5.1.1              |   py37h1de35cc_0         661 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    matplotlib-3.0.2           |   py37h54f8f79_0         6.5 MB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    kiwisolver-1.0.1           |   py37h0a44026_0          56 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    pyparsing-2.3.1            |           py37_0         105 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    pytz-2018.9                |           py37_0         268 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    cycler-0.10.0              |           py37_0          14 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    ca-certificates-2019.1.23  |                0         126 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    openssl-1.1.1b             |       h1de35cc_1         3.4 MB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    python-dateutil-2.8.0      |           py37_0         281 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    certifi-2019.3.9           |           py37_0         155 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    ------------------------------------------------------------
                                           Total:        11.6 MB

The following NEW packages will be INSTALLED:

    cycler:          0.10.0-py37_0        https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    kiwisolver:      1.0.1-py37h0a44026_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    matplotlib:      3.0.2-py37h54f8f79_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    pyparsing:       2.3.1-py37_0         https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    python-dateutil: 2.8.0-py37_0         https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    pytz:            2018.9-py37_0        https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    tornado:         5.1.1-py37h1de35cc_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main

The following packages will be UPDATED:

    ca-certificates: 2019.1.23-0          defaults                                                --> 2019.1.23-0       https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    certifi:         2019.3.9-py37_0      defaults                                                --> 2019.3.9-py37_0   https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    openssl:         1.1.1b-h1de35cc_1    defaults                                                --> 1.1.1b-h1de35cc_1 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main

Proceed ([y]/n)? y

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

 

之后如果設置了另一個函數再次進行install時,明明之前已經更改了channels,但如果還是遇見了這樣的問題:

(deeplearning2) userdeMBP:neural transfer user$ conda install matplotlib
Solving environment: failed

CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://repo.anaconda.com/pkgs/r/osx-64/repodata.json.bz2>

解決辦法就是退出該環境,使用-n來指明下載的環境,這樣就不會出現這樣的問題了:

userdeMBP:pytorch user$ conda install -n deeplearning2 matplotlib

 

但是最好還是直接進入該環境下,使用pip install來安裝包,不容易出錯


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM