写在前面:关于conda install各种库时报错:Solving environment: failed解决办法网上可以查到很多,可以参考这个,具体要看报错信息,这里我的并不太一样,所以解决办法也不同.
我是在激活虚拟环境后,然后将python版本进行了切换,切换到了虚拟环境的路径,所以导致conda install 报错.接下来切换会默认的python版本即可.将python切换会默认的2.7,python3切换回3.5
$ sudo update-alternatives --config python
有 3 个候选项可用于替换 python (提供 /usr/bin/python)。
选择 路径 优先级 状态
------------------------------------------------------------
0 /usr/bin/python2.7 1 自动模式
1 /home/mrips/anaconda3/envs/py36/bin/python3.6 1 手动模式
* 2 /usr/bin/python2.7 1 手动模式
3 /usr/bin/python3.5 1 手动模式
$ sudo update-alternatives --config python3
有 2 个候选项可用于替换 python3 (提供 /usr/bin/python3)。
选择 路径 优先级 状态
------------------------------------------------------------
0 /home/mrips/anaconda3/envs/py36/bin/python3.6 1 自动模式
* 1 /home/mrips/anaconda3/envs/py36/bin/python3.6 1 手动模式
2 /usr/bin/python3.5 1 手动模式
具体报错信息如下:
Solving environment: failed
WARNING conda.exceptions:print_unexpected_error_report(953): KeyError('pkgs_dirs',)
Traceback (most recent call last):
File "/home/mrips/anaconda3/lib/python3.6/site-packages/conda/gateways/connection/session.py", line 50, in __call__
return cls._thread_local.session
AttributeError: '_thread._local' object has no attribute 'session'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/mrips/anaconda3/lib/python3.6/site-packages/conda/exceptions.py", line 819, in __call__
return func(*args, **kwargs)
File "/home/mrips/anaconda3/lib/python3.6/site-packages/conda/cli/main.py", line 78, in _main
exit_code = do_call(args, p)
File "/home/mrips/anaconda3/lib/python3.6/site-packages/conda/cli/conda_argparse.py", line 77, in do_call
exit_code = getattr(module, func_name)(args, parser)
File "/home/mrips/anaconda3/lib/python3.6/site-packages/conda/cli/main_install.py", line 11, in execute
install(args, parser, 'install')
File "/home/mrips/anaconda3/lib/python3.6/site-packages/conda/cli/install.py", line 235, in install
force_reinstall=context.force,
File "/home/mrips/anaconda3/lib/python3.6/site-packages/conda/core/solve.py", line 505, in solve_for_transaction
force_remove, force_reinstall)
File "/home/mrips/anaconda3/lib/python3.6/site-packages/conda/core/solve.py", line 438, in solve_for_diff
final_precs = self.solve_final_state(deps_modifier, prune, ignore_pinned, force_remove)
File "/home/mrips/anaconda3/lib/python3.6/site-packages/conda/core/solve.py", line 179, in solve_final_state
index, r = self._prepare(prepared_specs)
File "/home/mrips/anaconda3/lib/python3.6/site-packages/conda/core/solve.py", line 560, in _prepare
self.subdirs, prepared_specs)
File "/home/mrips/anaconda3/lib/python3.6/site-packages/conda/core/index.py", line 215, in get_reduced_index
new_records = query_all(spec)
File "/home/mrips/anaconda3/lib/python3.6/site-packages/conda/core/index.py", line 184, in query_all
return tuple(concat(future.result() for future in as_completed(futures)))
File "/home/mrips/anaconda3/lib/python3.6/site-packages/conda/core/subdir_data.py", line 94, in query
self.load()
File "/home/mrips/anaconda3/lib/python3.6/site-packages/conda/core/subdir_data.py", line 148, in load
_internal_state = self._load()
File "/home/mrips/anaconda3/lib/python3.6/site-packages/conda/core/subdir_data.py", line 216, in _load
mod_etag_headers.get('_mod'))
File "/home/mrips/anaconda3/lib/python3.6/site-packages/conda/core/subdir_data.py", line 397, in fetch_repodata_remote_request
session = CondaSession()
File "/home/mrips/anaconda3/lib/python3.6/site-packages/conda/gateways/connection/session.py", line 52, in __call__
session = cls._thread_local.session = super(CondaSessionType, cls).__call__()
File "/home/mrips/anaconda3/lib/python3.6/site-packages/conda/gateways/connection/session.py", line 85, in __init__
self.headers['User-Agent'] = context.user_agent
File "/home/mrips/anaconda3/lib/python3.6/site-packages/conda/base/context.py", line 621, in user_agent
return _get_user_agent(self.platform)
File "/home/mrips/anaconda3/lib/python3.6/site-packages/conda/_vendor/auxlib/decorators.py", line 56, in _memoized_func
result = func(*args, **kwargs)
File "/home/mrips/anaconda3/lib/python3.6/site-packages/conda/base/context.py", line 918, in _get_user_agent
from .._vendor.distro import linux_distribution
File "/home/mrips/anaconda3/lib/python3.6/site-packages/conda/_vendor/distro.py", line 1084, in <module>
_distro = LinuxDistribution()
File "/home/mrips/anaconda3/lib/python3.6/site-packages/conda/_vendor/distro.py", line 600, in __init__
if include_lsb else {}
File "/home/mrips/anaconda3/lib/python3.6/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/mrips/anaconda3/lib/python3.6/site-packages/conda/exceptions.py", line 951, in print_unexpected_error_report
message_builder.append(get_main_info_str(error_report['conda_info']))
File "/home/mrips/anaconda3/lib/python3.6/site-packages/conda/cli/main_info.py", line 243, 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/mrips/anaconda3/lib/python3.6/site-packages/conda/gateways/connection/session.py", line 50, in __call__
return cls._thread_local.session
AttributeError: '_thread._local' object has no attribute 'session'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/mrips/anaconda3/lib/python3.6/site-packages/conda/exceptions.py", line 819, in __call__
return func(*args, **kwargs)
File "/home/mrips/anaconda3/lib/python3.6/site-packages/conda/cli/main.py", line 78, in _main
exit_code = do_call(args, p)
File "/home/mrips/anaconda3/lib/python3.6/site-packages/conda/cli/conda_argparse.py", line 77, in do_call
exit_code = getattr(module, func_name)(args, parser)
File "/home/mrips/anaconda3/lib/python3.6/site-packages/conda/cli/main_install.py", line 11, in execute
install(args, parser, 'install')
File "/home/mrips/anaconda3/lib/python3.6/site-packages/conda/cli/install.py", line 235, in install
force_reinstall=context.force,
File "/home/mrips/anaconda3/lib/python3.6/site-packages/conda/core/solve.py", line 505, in solve_for_transaction
force_remove, force_reinstall)
File "/home/mrips/anaconda3/lib/python3.6/site-packages/conda/core/solve.py", line 438, in solve_for_diff
final_precs = self.solve_final_state(deps_modifier, prune, ignore_pinned, force_remove)
File "/home/mrips/anaconda3/lib/python3.6/site-packages/conda/core/solve.py", line 179, in solve_final_state
index, r = self._prepare(prepared_specs)
File "/home/mrips/anaconda3/lib/python3.6/site-packages/conda/core/solve.py", line 560, in _prepare
self.subdirs, prepared_specs)
File "/home/mrips/anaconda3/lib/python3.6/site-packages/conda/core/index.py", line 215, in get_reduced_index
new_records = query_all(spec)
File "/home/mrips/anaconda3/lib/python3.6/site-packages/conda/core/index.py", line 184, in query_all
return tuple(concat(future.result() for future in as_completed(futures)))
File "/home/mrips/anaconda3/lib/python3.6/site-packages/conda/core/subdir_data.py", line 94, in query
self.load()
File "/home/mrips/anaconda3/lib/python3.6/site-packages/conda/core/subdir_data.py", line 148, in load
_internal_state = self._load()
File "/home/mrips/anaconda3/lib/python3.6/site-packages/conda/core/subdir_data.py", line 216, in _load
mod_etag_headers.get('_mod'))
File "/home/mrips/anaconda3/lib/python3.6/site-packages/conda/core/subdir_data.py", line 397, in fetch_repodata_remote_request
session = CondaSession()
File "/home/mrips/anaconda3/lib/python3.6/site-packages/conda/gateways/connection/session.py", line 52, in __call__
session = cls._thread_local.session = super(CondaSessionType, cls).__call__()
File "/home/mrips/anaconda3/lib/python3.6/site-packages/conda/gateways/connection/session.py", line 85, in __init__
self.headers['User-Agent'] = context.user_agent
File "/home/mrips/anaconda3/lib/python3.6/site-packages/conda/base/context.py", line 621, in user_agent
return _get_user_agent(self.platform)
File "/home/mrips/anaconda3/lib/python3.6/site-packages/conda/_vendor/auxlib/decorators.py", line 56, in _memoized_func
result = func(*args, **kwargs)
File "/home/mrips/anaconda3/lib/python3.6/site-packages/conda/base/context.py", line 918, in _get_user_agent
from .._vendor.distro import linux_distribution
File "/home/mrips/anaconda3/lib/python3.6/site-packages/conda/_vendor/distro.py", line 1084, in <module>
_distro = LinuxDistribution()
File "/home/mrips/anaconda3/lib/python3.6/site-packages/conda/_vendor/distro.py", line 600, in __init__
if include_lsb else {}
File "/home/mrips/anaconda3/lib/python3.6/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/mrips/anaconda3/bin/conda install numpy`
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?