-1

I want to downgrade from python 3.8.5 to 3.6 but I get some errors. my os is Ubuntu 20.4 and the version of conda is 4.9.2. When I run the command: conda install python=3.6 I get the following error:

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?
buran
  • 13,682
  • 10
  • 36
  • 61
dinan
  • 39
  • 6
  • Related: https://stackoverflow.com/questions/44967202/pip-is-showing-error-lsb-release-a-returned-non-zero-exit-status-1 – 9769953 Feb 27 '21 at 09:14
  • you mean you want to have multiple versions of python in your system? or just delete the 3.8.5 and install 3.6? – alexzander Feb 27 '21 at 09:15
  • multiple versions. Currently, I have 3.8.5 and 2.7, but can not install 3.6 – dinan Feb 27 '21 at 10:24
  • Conda should be able to install multiple versions next to each other; no need to delete other versions. – 9769953 Feb 27 '21 at 10:33
  • If you read the linked question, you may find that the `lsb_release` command is called with Python 3, while it is a Python 2 command. – 9769953 Feb 27 '21 at 10:34
  • I changed the first line of lsb_release, but again the same problem – dinan Feb 27 '21 at 11:02
  • What was the original first line of `lsb_release`, what is the current line of `lsb_release`, and what does `/usr/bin/python3 --version` give you? – 9769953 Feb 27 '21 at 13:17
  • The orginal: #!/usr/bin/python3 -Es The current: #! /usr/bin/python2.7 /usr/bin/python3 --version gives: Python 3.8.6 – dinan Feb 27 '21 at 14:37
  • Definitely revert it back to `#! /usr/bin/python3 -Es`, because Python 2 may be incompatible with this version of `lsb_release`. E.g, try running `lsb_release` before and after reverting your edit. – 9769953 Feb 27 '21 at 15:33

1 Answers1

0

It appears you are trying to install Python 3.6 through Conda from within a Conda environment (for Python 3.8).

Don't do that. Exit the Conda environment, and create a new 3.6 environment outside of the 3.8 environment.

You can't downgrade an existing Conda environment to a new Python version; especially not if the versions differ in major or minor versions. Package versions will not match with the Python version. It may work, but that's more likely luck than wisdom in such a case. The whole point of Conda is that it installs packages appropriate for your system and for the Python version of your choosing.

The reason for the error is that conda install expects the system Python version for some system information; that Python version lives at /usr/bin/python3, which is version 3.8, but since you run it inside a Conda environment that matches its own version, it will try and pick up the installed packages there (see the traceback: it shows anaconda3/lib/python3.8/site-packages/conda/_vendor/distro.py): this fails (probably because Conda's Python 3.8 variant doesn't include the details of your Ubuntu version).

Installing 3.6 outside of the current Conda environment should let the installation pick up the normal, system, Python version, and thus run lsb_release normally.

Make sure you revert your edit to /usr/bin/lsb_release, so that is runs with #! /usr/bin/python3 -Es again: Python 2 may not be compatible, and lsb_release may fail, resulting in another error, still in the installation process.

9769953
  • 10,344
  • 3
  • 26
  • 37
  • I exited the environment by the command 'deactivate', then I tried to install python3.6 and create an environment for that, again the same error. Could u please tell me the commands step by step? – dinan Mar 01 '21 at 07:41
  • Firstly: did you revert your edit for `/usr/bin/lsb_release`? – 9769953 Mar 01 '21 at 12:52
  • yes I did. even I want to uninstall Conda, I get the error: Collecting package metadata (current_repodata.json): failed WARNING conda.exceptions:print_unexpected_error_report(1213): KeyError('pkgs_dirs') – dinan Mar 01 '21 at 13:12
  • Do you get the same traceback as in your question? With the same `subprocess.CalledProcessError` error and the same paths shown? – 9769953 Mar 01 '21 at 13:31
  • (this may be a bit of a back and forth to get this sorted; usually easier locally than online, so I hope this will work.) – 9769953 Mar 01 '21 at 13:32
  • Also: in which directory are you trying to run the `conda` command? – 9769953 Mar 01 '21 at 13:34
  • Further: can you `lsb_release -a` just from the command line with no problem? – 9769953 Mar 01 '21 at 13:35