CondaHTTPError: HTTP 000 CONNECTION FAILED for url

郜杰
2023-12-01


前言

想运行一下这个开源项目https://github.com/viluiz/gan的代码,安装依赖时执行下面这句话:

conda env create -f environment.yml 

然后报错

CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/win-64/repodata.json>

在浏览器输入上面网址提示:Too many files to list


一、查看配置

首先打开cmd命令查看自己的conda的通道配置。

conda config --show

custom_channels:
  anaconda/pkgs/main: https://mirrors.tuna.tsinghua.edu.cn
  anaconda/pkgs/r: https://mirrors.tuna.tsinghua.edu.cn
  anaconda/pkgs/msys2: https://mirrors.tuna.tsinghua.edu.cn
  conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  pytorch-lts: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
custom_multichannels:
  defaults:
    - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
    - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2

二、解决办法

1、通过cmd修改

通过下面的cmd命令可以直接修改添加源(此办法我没有验证我用到下面的方法)

conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --set show_channel_urls yes

2、通过.condarc文件进行更改

在C:\Users\xxxx下找到文件.condarc:将https全部换成http即可

channels:
  - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
  - defaults
show_channel_urls: true
default_channels:
  - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
  - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
  conda-forge: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  msys2: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  bioconda: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  menpo: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  pytorch: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  pytorch-lts: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  simpleitk: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud

1、特别注意,如果.condarc文件找不到的话,是因为没有在cmd命令中输入 conda config命令,只有第一次输入该命令之后,系统才会自动创建.condarc文件。(.condarc指的是运行期配置文件)
2、如果原本的源中的源地址是 https,可以直接改成http即可。这个方法可以特别注意,因为https有时候会出现连接错误的问题,改成http后不会再出现此类问题。

三、新的问题

上面的问题解决了,安装了几分钟后又出现下面问题

conda env create -f environment.yml

Collecting package metadata (repodata.json): done
Solving environment: done
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
ERROR conda.core.link:_execute(699): An error occurred while installing package 'conda-forge::qt-5.12.9-h5909a2a_4'.
Rolling back transaction: done

LinkError: post-link script failed for package conda-forge::qt-5.12.9-h5909a2a_4
location of failed script: C:\Users\25212\anaconda3\envs\py3ml\Scripts\.qt-post-link.bat
==> script messages <==
<None>
==> script output <==
stdout:
stderr: Fatal Python error: init_import_site: Failed to import the site module
Python runtime state: initialized
Traceback (most recent call last):
  File "C:\Users\25212\anaconda3\lib\site.py", line 589, in <module>
    main()
  File "C:\Users\25212\anaconda3\lib\site.py", line 576, in main
    known_paths = addsitepackages(known_paths)
  File "C:\Users\25212\anaconda3\lib\site.py", line 359, in addsitepackages
    addsitedir(sitedir, known_paths)
  File "C:\Users\25212\anaconda3\lib\site.py", line 208, in addsitedir
    addpackage(sitedir, name, known_paths)
  File "C:\Users\25212\anaconda3\lib\site.py", line 164, in addpackage
    for n, line in enumerate(f):
  File "C:\Users\25212\anaconda3\lib\codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc4 in position 18: invalid continuation byte
return code: 1
()

看报错信息location of failed script: C:\Users\25212\anaconda3\envs\py3ml\Scripts.qt-post-link.bat 好像是目录C:\Users\25212\anaconda3\envs\py3ml\Scripts\下找不到qt-post-link.bat 这个文件,在anaconda3文件夹下搜索到了一个这个文件放了进去,然后继续执行

conda env create -f environment.yml 
结果显示
CondaValueError: prefix already exists: C:\Users\25212\anaconda3\envs\py3ml

应该是之前创建过同名的虚拟环境但是并没有成功创建完成导致的。

1、解决问题

1、查看conda环境信息

conda info

active environment : None
            shell level : 0
       user config file : C:\Users\25212\.condarc
 populated config files : C:\Users\25212\.condarc
          conda version : 4.10.3
    conda-build version : 3.21.6
         python version : 3.9.7.final.0
       virtual packages : __cuda=11.5=0
                          __win=0=0
                          __archspec=1=x86_64
       base environment : C:\Users\25212\anaconda3  (writable)
      conda av data dir : C:\Users\25212\anaconda3\etc\conda
  conda av metadata url : None
           channel URLs : http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/win-64
                          http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/noarch
                          http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/win-64
                          http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/noarch
                          http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r/win-64
                          http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r/noarch
                          http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2/win-64
                          http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2/noarch
          package cache : C:\Users\25212\anaconda3\pkgs
                          C:\Users\25212\.conda\pkgs
                          C:\Users\25212\AppData\Local\conda\conda\pkgs
       envs directories : C:\Users\25212\anaconda3\envs
                          C:\Users\25212\.conda\envs
                          C:\Users\25212\AppData\Local\conda\conda\envs
               platform : win-64
             user-agent : conda/4.10.3 requests/2.26.0 CPython/3.9.7 Windows/10 Windows/10.0.19043
          administrator : False
             netrc file : None
           offline mode : False

2、打开目录C:\Users\25212\anaconda3\envs\删掉py3ml文件夹即可,继续执行依然老样子,看https://github.com/ContinuumIO/anaconda-issues/issues/10949这个链接下有个解决办法是找到以下文件:“C:\Users\25212\anaconda3\pkgs\qt-5.12.9-h5909a2a_4\Scripts.qt-post-link.bat”,在文件的 @echo off这一行下面加上这句:

set PATH=%PATH%;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;

再尝试安装就可以了;于是加了这句话(分号也带着),然后又报错了:

conda env create -f environment.yml
Collecting package metadata (repodata.json): done
Solving environment: done
Preparing transaction: done
Verifying transaction: /
SafetyError: The package for qt located at C:\Users\25212\anaconda3\pkgs\qt-5.12.9-h5909a2a_4
appears to be corrupted. The path 'Scripts/.qt-post-link.bat'
has an incorrect size.
  reported size: 1242 bytes
  actual size: 1321 bytes

ClobberError: This transaction has incompatible packages due to a shared path.
  packages: conda-forge/win-64::tk-8.6.12-h8ffe710_0, conda-forge/win-64::xorg-xproto-7.0.31-hcd874cb_1007
  path: 'library/include/x11/deckeysym.h'


ClobberError: This transaction has incompatible packages due to a shared path.
  packages: conda-forge/win-64::tk-8.6.12-h8ffe710_0, conda-forge/win-64::xorg-xproto-7.0.31-hcd874cb_1007
  path: 'library/include/x11/hpkeysym.h'


ClobberError: This transaction has incompatible packages due to a shared path.
  packages: conda-forge/win-64::tk-8.6.12-h8ffe710_0, conda-forge/win-64::xorg-xproto-7.0.31-hcd874cb_1007
  path: 'library/include/x11/sunkeysym.h'


ClobberError: This transaction has incompatible packages due to a shared path.
  packages: conda-forge/win-64::tk-8.6.12-h8ffe710_0, conda-forge/win-64::xorg-xproto-7.0.31-hcd874cb_1007
  path: 'library/include/x11/x.h'


ClobberError: This transaction has incompatible packages due to a shared path.
  packages: conda-forge/win-64::tk-8.6.12-h8ffe710_0, conda-forge/win-64::xorg-xproto-7.0.31-hcd874cb_1007
  path: 'library/include/x11/xf86keysym.h'


ClobberError: This transaction has incompatible packages due to a shared path.
  packages: conda-forge/win-64::tk-8.6.12-h8ffe710_0, conda-forge/win-64::xorg-xproto-7.0.31-hcd874cb_1007
  path: 'library/include/x11/xatom.h'


ClobberError: This transaction has incompatible packages due to a shared path.
  packages: conda-forge/win-64::tk-8.6.12-h8ffe710_0, conda-forge/win-64::xorg-xproto-7.0.31-hcd874cb_1007
  path: 'library/include/x11/xfuncproto.h'


ClobberError: This transaction has incompatible packages due to a shared path.
  packages: conda-forge/win-64::tk-8.6.12-h8ffe710_0, conda-forge/win-64::xorg-libx11-1.7.2-hcd874cb_0
  path: 'library/include/x11/xlib.h'


ClobberError: This transaction has incompatible packages due to a shared path.
  packages: conda-forge/win-64::tk-8.6.12-h8ffe710_0, conda-forge/win-64::xorg-libx11-1.7.2-hcd874cb_0
  path: 'library/include/x11/xutil.h'


ClobberError: This transaction has incompatible packages due to a shared path.
  packages: conda-forge/win-64::tk-8.6.12-h8ffe710_0, conda-forge/win-64::xorg-xproto-7.0.31-hcd874cb_1007
  path: 'library/include/x11/ap_keysym.h'


ClobberError: This transaction has incompatible packages due to a shared path.
  packages: conda-forge/win-64::tk-8.6.12-h8ffe710_0, conda-forge/win-64::xorg-libx11-1.7.2-hcd874cb_0
  path: 'library/include/x11/cursorfont.h'


ClobberError: This transaction has incompatible packages due to a shared path.
  packages: conda-forge/win-64::tk-8.6.12-h8ffe710_0, conda-forge/win-64::xorg-xproto-7.0.31-hcd874cb_1007
  path: 'library/include/x11/keysym.h'


ClobberError: This transaction has incompatible packages due to a shared path.
  packages: conda-forge/win-64::tk-8.6.12-h8ffe710_0, conda-forge/win-64::xorg-xproto-7.0.31-hcd874cb_1007
  path: 'library/include/x11/keysymdef.h'



done
Executing transaction: done
ERROR conda.core.link:_execute(699): An error occurred while installing package 'conda-forge::qt-5.12.9-h5909a2a_4'.
Rolling back transaction: done

LinkError: post-link script failed for package conda-forge::qt-5.12.9-h5909a2a_4
location of failed script: C:\Users\25212\anaconda3\envs\py3ml\Scripts\.qt-post-link.bat
==> script messages <==
<None>
==> script output <==
stdout:
stderr: Fatal Python error: init_import_site: Failed to import the site module
Python runtime state: initialized
Traceback (most recent call last):
  File "C:\Users\25212\anaconda3\lib\site.py", line 589, in <module>
    main()
  File "C:\Users\25212\anaconda3\lib\site.py", line 576, in main
    known_paths = addsitepackages(known_paths)
  File "C:\Users\25212\anaconda3\lib\site.py", line 359, in addsitepackages
    addsitedir(sitedir, known_paths)
  File "C:\Users\25212\anaconda3\lib\site.py", line 208, in addsitedir
    addpackage(sitedir, name, known_paths)
  File "C:\Users\25212\anaconda3\lib\site.py", line 164, in addpackage
    for n, line in enumerate(f):
  File "C:\Users\25212\anaconda3\lib\codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc4 in position 18: invalid continuation byte
return code: 1
()

把添加的那句话的分号去掉;还是没解决。。。后面又试了更新conda

conda install conda --update-all

还是没用

又试了清理然后重新安装

conda clean --all

还是没用。。目前还未解决,先记录在这


20220311,又试了几个方法,把路径C:\Users\xxx\anaconda3\Library\bin下面的libcrypto-1_1-x64.dll和libssl-1_1-x64.dll复制到路径anaconda3\Dlls下;然后更新conda

conda update -n base conda
conda update --all

也没用完全解决,但好像能多往下走几个done。。


参考

参考文章:
https://blog.csdn.net/weixin_51484460/article/details/122179000
https://github.com/ContinuumIO/anaconda-issues/issues/10949
https://blog.csdn.net/weixin_43557139/article/details/120709295
https://blog.csdn.net/miaohang222/article/details/115342431
https://ask.csdn.net/questions/804335
https://www.pythonheidong.com/blog/article/453837/e72282b69ab0fff83894/
https://stackoverflow.com/questions/68083037/error-conda-core-link-execute699-an-error-occurred-while-installing-package

 类似资料:

相关阅读

相关文章

相关问答