python - 从 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, deps_modifier, prune, ignore_pinned,
File "/home/sare/anaconda3/lib/python3.8/site-packages/conda/core/solve.py", 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", 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, deps_modifier, prune, ignore_pinned,
File "/home/sare/anaconda3/lib/python3.8/site-packages/conda/core/solve.py", 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.
`$ /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 环境中运行它,它会尝试在那里拾取已安装的包(参见回溯:它显示anaconda3/lib/python3.8/site-packages/conda/_vendor/distro.py
):失败(可能是因为Conda 的 Python 3.8 变体不包括您的 Ubuntu 版本的详细信息)。
在当前 Conda 环境之外安装 3.6 应该让安装选择正常、系统、Python 版本,从而lsb_release
正常运行。
确保将您的编辑恢复为/usr/bin/lsb_release
,以便#! /usr/bin/python3 -Es
再次运行:Python 2 可能不兼容,并且lsb_release
可能失败,导致另一个错误,仍在安装过程中。
推荐阅读
- xcode - 如何在 React Native 项目中真正地在团队中工作?
- docker - docker-compose 错误:找不到指定的 Dockerfile
- image - 代号下载对其他应用可见的文件/图像
- node.js - 什么是 Firebase RefBuilder.onOperation
方法? - sql-server - 将列名放入sql server中的行
- batch-file - 通过批处理递归地为子文件夹中的所有文件名添加后缀
- r - 在 r 中下采样用于回归(非分类)
- angular - Angular Router:如何为一组子路由指定模板组件?
- excel - 如何滚动和选择/双击列表框项目?
- matlab - 任何有经验的 matlab 编码员可以建议提高我的代码效率的方法吗?