Anaconda 出现HTTP000报错的解决方法

在使用Anaconda 安装python的时候遇到这个错误

chen@chen-Standard-PC-i440FX-PIIX-1996:~$ conda create -n sdwebui python==3.10.9

Solving environment: failed

CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://repo.anaconda.com/pkgs/r/noarch/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.

SSLError(MaxRetryError('HTTPSConnectionPool(host=\'repo.anaconda.com\', port=443): Max retries exceeded with url: /pkgs/r/noarch/repodata.json.bz2 (Caused by SSLError(SSLError("bad handshake: Error([(\'SSL routines\', \'ssl3_get_server_certificate\', \'certificate verify failed\')])")))'))

 我看了下似乎是网络相关的问题,我第一时间想到的是源的问题,我主机的网络没问题,那就是源的问题

pip先更换一下清华源,等下方便下载

PIP设置国内源,由于默认源在国外,所以安装可能经常会出现timeout等问题,使用国内源可以很大程度避免下载包timeout的情况。将如下内容复制到文件~/.pip/pip.conf当中,如没有该文件,先创建touch ~/.pip/pip.conf

[global] 
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host = https://pypi.tuna.tsinghua.edu.cn

下面是更换Anaconda源为清华大学源

conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
conda config --set show_channel_urls yes
注意这里清华镜像源推荐使用http,而不是https,否则还有可能会报HTTP 000 CONNECTION FAILED的错误。

更改镜像源文件.condarc

这个文件.condarc 在用户主目录里面

将defaults这一行删掉

chen@chen-Standard-PC-i440FX-PIIX-1996:~$ vim  .condarc

channels:
  - http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
  - http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
  - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
  - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
show_channel_urls: true

删掉之后效果就是这样

再次运行命令

chen@chen-Standard-PC-i440FX-PIIX-1996:~$ conda create -n python3.10.9 python==3.10.9
Solving environment: done

## Package Plan ##

  environment location: /home/chen/anaconda3/envs/python3.10.9

  added / updated specs: 
    - python==3.10.9


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    _openmp_mutex-4.5          |            2_gnu          23 KB  http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
    wheel-0.38.4               |     pyhd8ed1ab_0          32 KB  http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
    ld_impl_linux-64-2.39      |       hc81fddc_0         759 KB  http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
    ncurses-6.4                |       h6a678d5_0         1.1 MB  http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    libzlib-1.2.13             |       h166bdaf_4          64 KB  http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
    pip-22.3.1                 |     pyhd8ed1ab_0         1.5 MB  http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
    zlib-1.2.13                |       h166bdaf_4          92 KB  http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
    libffi-3.4.2               |       h7f98852_5          57 KB  http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
    libgomp-12.2.0             |      h65d4601_19         455 KB  http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
    tzdata-2022f               |       h191b570_0         118 KB  http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
    libgcc-ng-12.2.0           |      h65d4601_19         931 KB  http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
    _libgcc_mutex-0.1          |      conda_forge           3 KB  http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
    sqlite-3.45.3              |       h5eee18b_0         1.6 MB  http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    python-3.10.9              |       h7a1cb2a_2        27.8 MB  http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    bzip2-1.0.8                |       h7f98852_4         484 KB  http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
    readline-8.1.2             |       h0f457ee_0         291 KB  http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
    ca-certificates-2022.9.24  |       ha878542_0         150 KB  http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
    tk-8.6.12                  |       h27826a3_0         3.3 MB  http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
    xz-5.4.6                   |       h5eee18b_1         700 KB  http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    setuptools-65.5.1          |     pyhd8ed1ab_0         731 KB  http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
    libuuid-1.41.5             |       h5eee18b_0          29 KB  http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    openssl-1.1.1w             |       h7f8727e_0         3.8 MB  http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    ------------------------------------------------------------
                                           Total:        43.9 MB

The following NEW packages will be INSTALLED:

    _libgcc_mutex:    0.1-conda_forge      http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
    _openmp_mutex:    4.5-2_gnu            http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
    bzip2:            1.0.8-h7f98852_4     http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
    ca-certificates:  2022.9.24-ha878542_0 http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
    ld_impl_linux-64: 2.39-hc81fddc_0      http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
    libffi:           3.4.2-h7f98852_5     http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
    libgcc-ng:        12.2.0-h65d4601_19   http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
    libgomp:          12.2.0-h65d4601_19   http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
    libuuid:          1.41.5-h5eee18b_0    http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main        
    libzlib:          1.2.13-h166bdaf_4    http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
    ncurses:          6.4-h6a678d5_0       http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main        
    openssl:          1.1.1w-h7f8727e_0    http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main        
    pip:              22.3.1-pyhd8ed1ab_0  http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
    python:           3.10.9-h7a1cb2a_2    http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main        
    readline:         8.1.2-h0f457ee_0     http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
    setuptools:       65.5.1-pyhd8ed1ab_0  http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
    sqlite:           3.45.3-h5eee18b_0    http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main        
    tk:               8.6.12-h27826a3_0    http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
    tzdata:           2022f-h191b570_0     http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
    wheel:            0.38.4-pyhd8ed1ab_0  http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
    xz:               5.4.6-h5eee18b_1     http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main        
    zlib:             1.2.13-h166bdaf_4    http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge

Proceed ([y]/n)? y


Downloading and Extracting Packages
_openmp_mutex-4.5    | 23 KB     | ################################################################################################################################################################################################################################### | 100% 
wheel-0.38.4         | 32 KB     | ################################################################################################################################################################################################################################### | 100% 
ld_impl_linux-64-2.3 | 759 KB    | ################################################################################################################################################################################################################################### | 100% 
ncurses-6.4          | 1.1 MB    | ################################################################################################################################################################################################################################### | 100% 
libzlib-1.2.13       | 64 KB     | ################################################################################################################################################################################################################################### | 100% 
pip-22.3.1           | 1.5 MB    | ################################################################################################################################################################################################################################### | 100% 
zlib-1.2.13          | 92 KB     | ################################################################################################################################################################################################################################### | 100% 
libffi-3.4.2         | 57 KB     | ################################################################################################################################################################################################################################### | 100% 
libgomp-12.2.0       | 455 KB    | ################################################################################################################################################################################################################################### | 100% 
tzdata-2022f         | 118 KB    | ################################################################################################################################################################################################################################### | 100% 
libgcc-ng-12.2.0     | 931 KB    | ################################################################################################################################################################################################################################### | 100% 
_libgcc_mutex-0.1    | 3 KB      | ################################################################################################################################################################################################################################### | 100% 
sqlite-3.45.3        | 1.6 MB    | ################################################################################################################################################################################################################################### | 100% 
python-3.10.9        | 27.8 MB   | ################################################################################################################################################################################################################################### | 100% 
bzip2-1.0.8          | 484 KB    | ################################################################################################################################################################################################################################### | 100% 
readline-8.1.2       | 291 KB    | ################################################################################################################################################################################################################################### | 100% 
ca-certificates-2022 | 150 KB    | ################################################################################################################################################################################################################################### | 100% 
tk-8.6.12            | 3.3 MB    | ################################################################################################################################################################################################################################### | 100% 
xz-5.4.6             | 700 KB    | ################################################################################################################################################################################################################################### | 100% 
setuptools-65.5.1    | 731 KB    | ################################################################################################################################################################################################################################### | 100% 
libuuid-1.41.5       | 29 KB     | ################################################################################################################################################################################################################################### | 100% 
openssl-1.1.1w       | 3.8 MB    | ################################################################################################################################################################################################################################### | 100% 
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use:
# > source activate python3.10.9
#
# To deactivate an active environment, use:
# > source deactivate
#

安装完成

当在Anaconda Spyder环境中遇到`RuntimeError: This event loop is already running`这样的错误时,通常是因为你在尝试在一个已经激活的事件循环中创建新的任务。协程(coroutines)和异步编程在Python中通常通过`asyncio`库处理,它们依赖于事件循环来管理并发操作。 解决这个问题有几种可能的方法: 1. **停止当前事件循环**:如果你正试图在一个已经运行的协程内部启动新任务,需要先等待当前任务完成再继续。可以使用`await asyncio.sleep(0)`让当前任务执行完毕。 ```python if asyncio.is_running(): await asyncio.sleep(0) ``` 2. **使用`asyncio.create_task`而非`run_until_complete`**:如果你想要在现有的事件循环上启动一个新的协程,应该使用`asyncio.create_task`代替`asyncio.run`或`asyncio.get_event_loop().run_until_complete()`。 ```python loop = asyncio.get_event_loop() task = asyncio.create_task(some_coroutine()) ``` 3. **在函数外部创建任务**:如果协程在函数内,确保该函数外有一个事件循环实例,并在外部创建任务。 ```python async def my_coroutine(): # your coroutine code here event_loop = asyncio.get_event_loop() future = event_loop.create_task(my_coroutine()) # 如果你想阻塞在这里等待任务完成 result = await future ``` 4. **检查是否有重复的事件循环**:确保在整个程序中只存在一个有效的`asyncio`事件循环。避免在不同的地方创建并使用多个事件循环。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

java-superchen

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值