如何解决从 python 3.8.5 降级到 python 3.6
我想从 python 3.8.5 降级到 3.6,但出现一些错误。 我的操作系统是 Ubuntu 20.4,conda 的版本是 4.9.2。 当我运行命令时: conda install python=3.6 我收到以下错误:
Collecting package Metadata (current_repodata.json): Failed
WARNING conda.exceptions:print_unexpected_error_report(1213): KeyError('pkgs_dirs')
Traceback (most recent call last):
File "/home/sare/anaconda3/lib/python3.8/site-packages/conda/exceptions.py",line 1079,in __call__
return func(*args,**kwargs)
File "/home/sare/anaconda3/lib/python3.8/site-packages/conda/cli/main.py",line 84,in _main
exit_code = do_call(args,p)
File "/home/sare/anaconda3/lib/python3.8/site-packages/conda/cli/conda_argparse.py",line 83,in do_call
return getattr(module,func_name)(args,parser)
File "/home/sare/anaconda3/lib/python3.8/site-packages/conda/cli/main_install.py",line 20,in execute
install(args,parser,'install')
File "/home/sare/anaconda3/lib/python3.8/site-packages/conda/cli/install.py",line 261,in install
unlink_link_transaction = solver.solve_for_transaction(
File "/home/sare/anaconda3/lib/python3.8/site-packages/conda/core/solve.py",line 114,in solve_for_transaction
unlink_precs,link_precs = self.solve_for_diff(update_modifier,deps_modifier,File "/home/sare/anaconda3/lib/python3.8/site-packages/conda/core/solve.py",line 157,in solve_for_diff
final_precs = self.solve_final_state(update_modifier,prune,ignore_pinned,line 262,in solve_final_state
ssc = self._collect_all_Metadata(ssc)
File "/home/sare/anaconda3/lib/python3.8/site-packages/conda/common/io.py",line 88,in decorated
return f(*args,**kwds)
File "/home/sare/anaconda3/lib/python3.8/site-packages/conda/core/solve.py",line 397,in _collect_all_Metadata
_supplement_index_with_system(virtual_pkg_index)
File "/home/sare/anaconda3/lib/python3.8/site-packages/conda/core/index.py",line 163,in _supplement_index_with_system
dist_name,dist_version = context.os_distribution_name_version
File "/home/sare/anaconda3/lib/python3.8/site-packages/conda/_vendor/auxlib/decorators.py",line 268,in new_fget
cache[inner_attname] = func(self)
File "/home/sare/anaconda3/lib/python3.8/site-packages/conda/base/context.py",line 786,in os_distribution_name_version
from .._vendor.distro import id,version
File "/home/sare/anaconda3/lib/python3.8/site-packages/conda/_vendor/distro.py",line 1084,in <module>
_distro = Linuxdistribution()
File "/home/sare/anaconda3/lib/python3.8/site-packages/conda/_vendor/distro.py",line 599,in __init__
self._lsb_release_info = self._get_lsb_release_info() \
File "/home/sare/anaconda3/lib/python3.8/site-packages/conda/_vendor/distro.py",line 943,in _get_lsb_release_info
raise subprocess.CalledProcessError(code,cmd,stdout,stderr)
subprocess.CalledProcessError: Command 'lsb_release -a' returned non-zero exit status 1.
During handling of the above exception,another exception occurred:
Traceback (most recent call last):
File "/home/sare/anaconda3/lib/python3.8/site-packages/conda/exceptions.py",line 1211,in print_unexpected_error_report
message_builder.append(get_main_info_str(error_report['conda_info']))
File "/home/sare/anaconda3/lib/python3.8/site-packages/conda/cli/main_info.py",line 238,in get_main_info_str
info_dict['_' + key] = ('\n' + 26 * ' ').join(info_dict[key])
KeyError: 'pkgs_dirs'
# >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<
Traceback (most recent call last):
File "/home/sare/anaconda3/lib/python3.8/site-packages/conda/exceptions.py",in __call__
return func(*args,**kwargs)
File "/home/sare/anaconda3/lib/python3.8/site-packages/conda/cli/main.py",in _main
exit_code = do_call(args,p)
File "/home/sare/anaconda3/lib/python3.8/site-packages/conda/cli/conda_argparse.py",in do_call
return getattr(module,parser)
File "/home/sare/anaconda3/lib/python3.8/site-packages/conda/cli/main_install.py",in execute
install(args,'install')
File "/home/sare/anaconda3/lib/python3.8/site-packages/conda/cli/install.py",in install
unlink_link_transaction = solver.solve_for_transaction(
File "/home/sare/anaconda3/lib/python3.8/site-packages/conda/core/solve.py",in solve_for_transaction
unlink_precs,in solve_for_diff
final_precs = self.solve_final_state(update_modifier,in solve_final_state
ssc = self._collect_all_Metadata(ssc)
File "/home/sare/anaconda3/lib/python3.8/site-packages/conda/common/io.py",in decorated
return f(*args,**kwds)
File "/home/sare/anaconda3/lib/python3.8/site-packages/conda/core/solve.py",in _collect_all_Metadata
_supplement_index_with_system(virtual_pkg_index)
File "/home/sare/anaconda3/lib/python3.8/site-packages/conda/core/index.py",in _supplement_index_with_system
dist_name,dist_version = context.os_distribution_name_version
File "/home/sare/anaconda3/lib/python3.8/site-packages/conda/_vendor/auxlib/decorators.py",in new_fget
cache[inner_attname] = func(self)
File "/home/sare/anaconda3/lib/python3.8/site-packages/conda/base/context.py",in os_distribution_name_version
from .._vendor.distro import id,version
File "/home/sare/anaconda3/lib/python3.8/site-packages/conda/_vendor/distro.py",in <module>
_distro = Linuxdistribution()
File "/home/sare/anaconda3/lib/python3.8/site-packages/conda/_vendor/distro.py",in __init__
self._lsb_release_info = self._get_lsb_release_info() \
File "/home/sare/anaconda3/lib/python3.8/site-packages/conda/_vendor/distro.py",in _get_lsb_release_info
raise subprocess.CalledProcessError(code,stderr)
subprocess.CalledProcessError: Command 'lsb_release -a' returned non-zero exit status 1.
`$ /home/sare/anaconda3/bin/conda install python=3.6.0`
environment variables:
conda info Could not be constructed.
KeyError('pkgs_dirs')
An unexpected error has occurred. Conda has prepared the above report.
If submitted,this report will be used by core maintainers to improve
future releases of conda.
Would you like conda to send this report to the core maintainers?
解决方法
您似乎正在尝试通过 Conda 在 Conda 环境中安装 Python 3.6(适用于 Python 3.8)。
不要那样做。退出 Conda 环境,并在 3.8 环境之外创建一个新 3.6 环境。
您不能将现有的 Conda 环境降级到新的 Python 版本;特别是如果版本在主要或次要版本中不同。包版本将与 Python 版本不匹配。它可能有效,但在这种情况下,这更可能是运气而不是智慧。 Conda 的全部意义在于它安装适合您系统和的软件包,适用于您选择的 Python 版本。
错误的原因是conda install
对某些系统信息期望系统Python版本; Python 版本位于 /usr/bin/python3
,即 3.8 版,但是由于您在与其自己版本匹配的 Conda 环境中运行它,它会尝试在那里获取已安装的软件包(请参阅回溯:它显示 {{ 1}}):这失败了(可能是因为 Conda 的 Python 3.8 变体不包含您的 Ubuntu 版本的详细信息)。
在当前 Conda 环境之外安装 3.6 应该让安装选择正常的、系统的、Python 版本,从而正常运行 anaconda3/lib/python3.8/site-packages/conda/_vendor/distro.py
。
确保将您的编辑恢复为 lsb_release
,以便再次使用 /usr/bin/lsb_release
运行:Python 2 可能不兼容,并且 #! /usr/bin/python3 -Es
可能会失败,导致另一个错误,仍然在安装过程中。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。