The spyder/conda installation package reports an error: conda info could not be constructed. KeyError: 'pkgs_dirs'

Open conda , the error characteristics are as follows:

error message

insert image description here
Open powershell, enter conda info and report an error.

(base) PS C:\Users\Administrator> conda info

# >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<

    Traceback (most recent call last):
      File "C:\ProgramData\anaconda3\lib\site-packages\conda\exceptions.py", line 1082, in __call__
        return func(*args, **kwargs)
      File "C:\ProgramData\anaconda3\lib\site-packages\conda\cli\main.py", line 87, in _main
        exit_code = do_call(args, p)
      File "C:\ProgramData\anaconda3\lib\site-packages\conda\cli\conda_argparse.py", line 84, in do_call
        return getattr(module, func_name)(args, parser)
      File "C:\ProgramData\anaconda3\lib\site-packages\conda\cli\main_info.py", line 317, in execute
        info_dict = get_info_dict(args.system)
      File "C:\ProgramData\anaconda3\lib\site-packages\conda\cli\main_info.py", line 163, in get_info_dict
        pkgs_dirs=context.pkgs_dirs,
      File "C:\ProgramData\anaconda3\lib\site-packages\conda\base\context.py", line 530, in pkgs_dirs
        fixed_dirs += user_data_dir(APP_NAME, APP_NAME),
      File "C:\ProgramData\anaconda3\lib\site-packages\conda\_vendor\appdirs.py", line 67, in user_data_dir
        path = os.path.join(_get_win_folder(const), appauthor, appname)
      File "C:\ProgramData\anaconda3\lib\site-packages\conda\_vendor\appdirs.py", line 284, in _get_win_folder_with_pywin32
        from win32com.shell import shellcon, shell
    ImportError: DLL load failed while importing shell: The specified program could not be found.

`$ C:\ProgramData\anaconda3\Scripts\conda-script.py info`


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?

[y/N]: n

No report sent. To permanently opt-out, use

    $ conda config --set report_errors false
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37

The same error is reported when installing any package. . . .

(base) PS C:\Users\Administrator> conda install pybindll
Collecting package metadata (current_repodata.json): failed
WARNING conda.exceptions:print_unexpected_error_report(1216): KeyError('pkgs_dirs')
Traceback (most recent call last):
  File "C:\ProgramData\anaconda3\lib\site-packages\conda\exceptions.py", line 1082, in __call__
    return func(*args, **kwargs)
  File "C:\ProgramData\anaconda3\lib\site-packages\conda\cli\main.py", line 87, in _main
    exit_code = do_call(args, p)
  File "C:\ProgramData\anaconda3\lib\site-packages\conda\cli\conda_argparse.py", line 84, in do_call
    return getattr(module, func_name)(args, parser)
  File "C:\ProgramData\anaconda3\lib\site-packages\conda\cli\main_install.py", line 20, in execute
    install(args, parser, 'install')
  File "C:\ProgramData\anaconda3\lib\site-packages\conda\cli\install.py", line 260, in install
    unlink_link_transaction = solver.solve_for_transaction(
  File "C:\ProgramData\anaconda3\lib\site-packages\conda\core\solve.py", line 152, in solve_for_transaction
    unlink_precs, link_precs = self.solve_for_diff(update_modifier, deps_modifier,
  File "C:\ProgramData\anaconda3\lib\site-packages\conda\core\solve.py", line 195, in solve_for_diff
    final_precs = self.solve_final_state(update_modifier, deps_modifier, prune, ignore_pinned,
  File "C:\ProgramData\anaconda3\lib\site-packages\conda\core\solve.py", line 300, in solve_final_state
    ssc = self._collect_all_metadata(ssc)
  File "C:\ProgramData\anaconda3\lib\site-packages\conda\common\io.py", line 88, in decorated
    return f(*args, **kwds)
  File "C:\ProgramData\anaconda3\lib\site-packages\conda\core\solve.py", line 463, in _collect_all_metadata
    index, r = self._prepare(prepared_specs)
  File "C:\ProgramData\anaconda3\lib\site-packages\conda\core\solve.py", line 1058, in _prepare
    reduced_index = get_reduced_index(self.prefix, self.channels,
  File "C:\ProgramData\anaconda3\lib\site-packages\conda\core\index.py", line 288, in get_reduced_index
    new_records = SubdirData.query_all(spec, channels=channels, subdirs=subdirs,
  File "C:\ProgramData\anaconda3\lib\site-packages\conda\core\subdir_data.py", line 118, in query_all
    create_cache_dir()
  File "C:\ProgramData\anaconda3\lib\site-packages\conda\core\subdir_data.py", line 876, in create_cache_dir
    cache_dir = join(PackageCacheData.first_writable().pkgs_dir, 'cache')
  File "C:\ProgramData\anaconda3\lib\site-packages\conda\core\package_cache_data.py", line 151, in first_writable
    pkgs_dirs = context.pkgs_dirs
  File "C:\ProgramData\anaconda3\lib\site-packages\conda\base\context.py", line 530, in pkgs_dirs
    fixed_dirs += user_data_dir(APP_NAME, APP_NAME),
  File "C:\ProgramData\anaconda3\lib\site-packages\conda\_vendor\appdirs.py", line 67, in user_data_dir
    path = os.path.join(_get_win_folder(const), appauthor, appname)
  File "C:\ProgramData\anaconda3\lib\site-packages\conda\_vendor\appdirs.py", line 284, in _get_win_folder_with_pywin32
    from win32com.shell import shellcon, shell
ImportError: DLL load failed while importing shell: The specified program could not be found.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\ProgramData\anaconda3\lib\site-packages\conda\exceptions.py", line 1214, in print_unexpected_error_report
    message_builder.append(get_main_info_str(error_report['conda_info']))
  File "C:\ProgramData\anaconda3\lib\site-packages\conda\cli\main_info.py", line 237, 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 "C:\ProgramData\anaconda3\lib\site-packages\conda\exceptions.py", line 1082, in __call__
        return func(*args, **kwargs)
      File "C:\ProgramData\anaconda3\lib\site-packages\conda\cli\main.py", line 87, in _main
        exit_code = do_call(args, p)
      File "C:\ProgramData\anaconda3\lib\site-packages\conda\cli\conda_argparse.py", line 84, in do_call
        return getattr(module, func_name)(args, parser)
      File "C:\ProgramData\anaconda3\lib\site-packages\conda\cli\main_install.py", line 20, in execute
        install(args, parser, 'install')
      File "C:\ProgramData\anaconda3\lib\site-packages\conda\cli\install.py", line 260, in install
        unlink_link_transaction = solver.solve_for_transaction(
      File "C:\ProgramData\anaconda3\lib\site-packages\conda\core\solve.py", line 152, in solve_for_transaction
        unlink_precs, link_precs = self.solve_for_diff(update_modifier, deps_modifier,
      File "C:\ProgramData\anaconda3\lib\site-packages\conda\core\solve.py", line 195, in solve_for_diff
        final_precs = self.solve_final_state(update_modifier, deps_modifier, prune, ignore_pinned,
      File "C:\ProgramData\anaconda3\lib\site-packages\conda\core\solve.py", line 300, in solve_final_state
        ssc = self._collect_all_metadata(ssc)
      File "C:\ProgramData\anaconda3\lib\site-packages\conda\common\io.py", line 88, in decorated
        return f(*args, **kwds)
      File "C:\ProgramData\anaconda3\lib\site-packages\conda\core\solve.py", line 463, in _collect_all_metadata
        index, r = self._prepare(prepared_specs)
      File "C:\ProgramData\anaconda3\lib\site-packages\conda\core\solve.py", line 1058, in _prepare
        reduced_index = get_reduced_index(self.prefix, self.channels,
      File "C:\ProgramData\anaconda3\lib\site-packages\conda\core\index.py", line 288, in get_reduced_index
        new_records = SubdirData.query_all(spec, channels=channels, subdirs=subdirs,
      File "C:\ProgramData\anaconda3\lib\site-packages\conda\core\subdir_data.py", line 118, in query_all
        create_cache_dir()
      File "C:\ProgramData\anaconda3\lib\site-packages\conda\core\subdir_data.py", line 876, in create_cache_dir
        cache_dir = join(PackageCacheData.first_writable().pkgs_dir, 'cache')
      File "C:\ProgramData\anaconda3\lib\site-packages\conda\core\package_cache_data.py", line 151, in first_writable
        pkgs_dirs = context.pkgs_dirs
      File "C:\ProgramData\anaconda3\lib\site-packages\conda\base\context.py", line 530, in pkgs_dirs
        fixed_dirs += user_data_dir(APP_NAME, APP_NAME),
      File "C:\ProgramData\anaconda3\lib\site-packages\conda\_vendor\appdirs.py", line 67, in user_data_dir
        path = os.path.join(_get_win_folder(const), appauthor, appname)
      File "C:\ProgramData\anaconda3\lib\site-packages\conda\_vendor\appdirs.py", line 284, in _get_win_folder_with_pywin32
        from win32com.shell import shellcon, shell
    ImportError: DLL load failed while importing shell: The specified program could not be found.

`$ C:\ProgramData\anaconda3\Scripts\conda-script.py install pybindll`

  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?

[y/N]: n

No report sent. To permanently opt-out, use

    $ conda config --set report_errors false

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110

I have tried many online methods, and the environment variables are no problem. Finally, the reinstallation of conda still does not work. The final solution is as follows:

Solution:

turn upC:\Users\{username}\AppData\Roaming\Python\Python{version}\site-packagesthis path, deletesite-packagesThis folder, the conda error will disappear.

enterconda infoVerification:
insert image description here
There is no problem, indicating that the problem is solved.

problem analysis:

After conda is installed, as you can see from the above,conda installAutomatically downloaded scripts and installation packages are available atC:\ProgramData\anaconda3\pkgs; C:\Users\Administrator\.conda\pkgs; C:\Users\Administrator\AppData\Local\conda\conda\pkgs

The default installation address for pip to install various packages isC:\Users\{username}\AppData\Roaming\Python\Python{version}\site-packages; C:\Users\{username}\AppData\Roaming\Python\Python{version}\scripts; here it is possible to passpython -m siteCommand view:
insert image description here
where USER_BASE and USER_SITE are the base paths of the scripts and dependent installation packages that python automatically downloads through pip by default. (I doesn't exist here because I have deleted this folder)
and then use the commandpython -m site -help, you can see
insert image description here
that this path configuration is in the file anaconda3\lib\site.py. This can be modified and replaced with the installation path of your own scripts and packages.
can be used againpython -m siteto see if the replacement is successful

PS: One more word, as mentioned in the official conda issue, try not to use pip and conda mixed installation, because there are differences in the binary compilation of the two installation methods, it is not clear whether it has anything to do with this, but pip and conda are the best is often only one way.

References:

Windows conda ImportError: DLL load failed while importing shell

Tags: The spyder/conda installation package reports an error: conda info could not be constructed. KeyError: 'pkgs_dirs'

Environment configuration conda/pip error collection conda python pip error

Related: The spyder/conda installation package reports an error: conda info could not be constructed. KeyError: 'pkgs_dirs'