昨天我在用Anaconda在Linux服务器上安装tensorflow的时候,发现无法更新、安装、卸载软件包,也无法创建新的conda环境,全部返回了错误...
昨天我在使用 Anaconda 在 Linux 服务器上安装 tensorflow 时,发现无法更新、安装、卸载软件包,也无法创建新的 conda 环境,在收集软件包元数据时都返回了同样的错误:
(base) user@servername:~$ conda update conda
Channels:
- defaults
Platform: linux-64
Collecting package metadata (repodata.json): \ Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: EE certificate key too weak (_ssl.c:1006)'))': /pkgs/r/noarch/repodata.json
failed
CondaSSLError: Encountered an SSL error. Most likely a certificate verification issue.
Exception: HTTPSConnectionPool(host='repo.anaconda.com', port=443): Max retries exceeded with url: /pkgs/main/linux-64/repodata.json (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: EE certificate key too weak (_ssl.c:1006)')))
仅供参考,我是该服务器的临时用户,无法使用 sudo。我无法使用 pip,因为它也需要 sudo 才能安装。我使用的是 Anaconda 24.1.2 和 ubuntu 20.04.3。昨天之前一切正常。以下是我尝试解决问题的一些方法:
-
我使用和未使用 VPN(绕过互联网审查的 VPN)连接到了服务器,但没有显示出任何区别。
-
我删除并安装了 Anaconda 几次,但没有起作用。
-
切换到清华镜像仓库,还是没啥区别。我的.condarc 文件如下。既然没啥区别,我就改回默认仓库了。
channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/linux-64
show_channel_urls: true
-
我根据 KWA 但错误仍然一样。
-
然后我尝试通过 来设置 ssl_verify 为 false
conda config --set ssl_verify False
,错误信息被修改为 UnicodeDecoderError ,详细错误报告如下。
(base) user@servername:~$ conda update conda
Channels:
- defaults
Platform: linux-64
Collecting package metadata (repodata.json): failed
# >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<
Traceback (most recent call last):
File "/home/user/anaconda3/lib/python3.11/site-packages/conda/exception_handler.py", line 17, in __call__
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
...
...
^^^^^^^^^^^^^^^^^^^
File "/home/user/anaconda3/lib/python3.11/site-packages/conda/gateways/repodata/__init__.py", line 858, in fetch_latest
raw_repodata = self.cache_path_json.read_text()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/anaconda3/lib/python3.11/pathlib.py", line 1059, in read_text
return f.read()
^^^^^^^^
File "<frozen codecs>", line 322, in decode
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc9 in position 465: invalid continuation byte
-
我尝试通过以下方式清理缓存
conda clean --all
-
我通过以下方式指定了编码方法
export PYTHONIOENCODING=utf-8
-
以上两种方法都没有改变错误报告。然后,我到达文件/home/user/anaconda3/lib/python3.11/pathlib.py,并将原始文件中的解码方法从
def read_text(self, encoding=None, errors=None):
"""
Open the file in text mode, read it, and close the file.
"""
encoding = io.text_encoding(encoding)
with self.open(mode='r', encoding=encoding, errors=errors) as f:
return f.read()
至(也尝试过“latin-1”)
def read_text(self, encoding="gbk", errors=None):
"""
Open the file in text mode, read it, and close the file.
"""
encoding = io.text_encoding(encoding)
with self.open(mode='r', encoding=encoding, errors=errors) as f:
return f.read()
它返回错误
(base) user@servername:~$ conda update conda
Channels:
- defaults
Platform: linux-64
Collecting package metadata (repodata.json): failed
# >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<
Traceback (most recent call last):
File "/home/user/anaconda3/lib/python3.11/site-packages/conda/exception_handler.py", line 17, in __call__
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
...
...
File "/home/user/anaconda3/lib/python3.11/site-packages/conda_libmamba_solver/index.py", line 337, in _load_channels
info = self._json_path_to_repo_info(url, jsons[url])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/anaconda3/lib/python3.11/site-packages/conda_libmamba_solver/index.py", line 293, in _json_path_to_repo_info
repo = api.Repo(self._pool, noauth_url, str(path_to_use), escape_channel_url(noauth_url))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: Unable to read repodata JSON file 'https://repo.anaconda.com/pkgs/main/linux-64', error was: repository does not start with an object
还有其他方法可以让我的 conda 安装软件包并创建虚拟环境吗?任何见解都将不胜感激。非常感谢!
正如我之前所说,我想像往常一样使用我的 conda 来安装和卸载软件包并创建虚拟环境。