R-install_miniconda() uninstall | conda command line error and solution

When running the following code, an error suddenly occurs:

C:\Users\hp>conda info-e

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

Traceback (most recent call last):
  File "C:\Users\hp\AppData\Local\r-miniconda\Lib\site-packages\conda\exception_handler.py", line 17, in __call__
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\hp\AppData\Local\r-miniconda\Lib\site-packages\conda\cli\main.py", line 61, in main_subshell
    context.__init__(argparse_args=pre_args)
  File "C:\Users\hp\AppData\Local\r-miniconda\Lib\site-packages\conda\base\context.py", line 456, in __init__
    self._set_search_path(
  File "C:\Users\hp\AppData\Local\r-miniconda\Lib\site-packages\conda\common\configuration.py", line 1428, in _set_search_path
    self._set_raw_data(dict(self._load_search_path(self._search_path)))
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\hp\AppData\Local\r-miniconda\Lib\site-packages\conda\common\configuration.py", line 1417, in _load_search_path
    yield path, YamlRawParameter.make_raw_parameters_from_file(path)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^
  File "C:\Users\hp\AppData\Local\r-miniconda\Lib\site-packages\conda\common\configuration.py", line 401, in make_raw_parameters_from_file
    yaml_obj = yaml_round_trip_load(fh)
               ^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\hp\AppData\Local\r-miniconda\Lib\site-packages\conda\common\serialize.py", line 43, in yaml_round_trip_load
    return _yaml_round_trip().load(string)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\hp\AppData\Local\r-miniconda\Lib\site-packages\ruamel\yaml\main.py", line 432, in load
    constructor, parser = self.get_constructor_parser(stream)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\hp\AppData\Local\r-miniconda\Lib\site-packages\ruamel\yaml\main.py", line 483, in get_constructor_parser
    self.reader.stream = stream
    ^^^^^^^^^^^^^^^^^
  File "C:\Users\hp\AppData\Local\r-miniconda\Lib\site-packages\ruamel\yaml\reader.py", line 133, in stream
    self.determine_encoding()
  File "C:\Users\hp\AppData\Local\r-miniconda\Lib\site-packages\ruamel\yaml\reader.py", line 193, in determine_encoding
    self.update_raw()
  File "C:\Users\hp\AppData\Local\r-miniconda\Lib\site-packages\ruamel\yaml\reader.py", line 288, in update_raw
    data = self.stream.read(size)
           ^^^^^^^^^^^^^^^^^^^^^
UnicodeDecodeError: 'gbk' codec can't decode byte 0xab in position 612: illegal multibyte sequence
`$ C:\Users\hp\AppData\Local\r-miniconda\Scripts\conda-script.py info-e`


An unexpected error has occurred. Conda has prepared the above report.
If you suspect this error is being caused by a malfunctioning plugin,
consider using the --no-plugins option to turn off plugins.

Example: conda --no-plugins install <package>

Alternatively, you can set the CONDA_NO_PLUGINS environment variable on
the command line to run the command without plugins enabled.

Example: CONDA_NO_PLUGINS=true conda install <package>

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]:

After the above error message suddenly appears, uninstall miniconda:

  1. Delete the envs and pkgs folders in the miniconda installation directory;
  2. Run the Miniconda unistall.exe application in the miniconda installation directory to uninstall the software package.

After uninstalling and reinstalling in R, the following error message appears:

install_miniconda() #Install miniconda environment

  • Installing Miniconda – please wait a moment…
  • Downloading “https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe” …
    trying URL https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe’
    Warning: URL ‘https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe’: status was ‘Couldn’t resolve host name’Error in download.file(url, destfile = installer, mode = “wb”):
    cannot open URL https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe’

Workaround: After turning off the proxy, run the code again.

> install_miniconda() # Install miniconda environment
* Installing Miniconda -- please wait a moment ...
* Downloading "https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe" ...
trying URL 'https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe'
Content type 'application/octet-stream' length 77445248 bytes (73.9 MB)
downloaded 73.9 MB

 + "C:/Users/hp/AppData/Local/r-miniconda/condabin/conda.bat" update --yes --name base conda
Collecting package metadata (current_repodata.json): ...working... done
Solving environment: ...working... done

## Package Plan ##

  environment location: C:\Users\hp\AppData\Local\R-MINI~1

  added/updated specs:
    -conda


The following packages will be downloaded:

    package | build
    -------------------------------|-----------------
    archspec-0.2.1 | pyhd3eb1b0_0 39 KB
    brotli-python-1.0.9 | py311hd77b12b_7 310 KB
    conda-23.10.0 | py311haa95532_0 1.2 MB
    conda-libmamba-solver-23.11.0|py311haa95532_0 103 KB
    libmamba-1.5.3 | hcd6fe79_0 3.8 MB
    libmambapy-1.5.3 | py311h77c03ed_0 323 KB
    openssl-3.0.12 | h2bbff1b_0 7.4 MB
    urllib3-1.26.18 | py311haa95532_0 252 KB
    yaml-cpp-0.8.0 | hd77b12b_0 2.0 MB
    -------------------------------------------------- ----------
                                           Total: 15.5 MB

The following NEW packages will be INSTALLED:

  archspec pkgs/main/noarch::archspec-0.2.1-pyhd3eb1b0_0
  brotli-python pkgs/main/win-64::brotli-python-1.0.9-py311hd77b12b_7

The following packages will be REMOVED:

  brotlipy-0.7.0-py311h2bbff1b_1002

The following packages will be UPDATED:

  conda 23.9.0-py311haa95532_0 --> 23.10.0-py311haa95532_0
  conda-libmamba-so~ 23.9.1-py311haa95532_0 --> 23.11.0-py311haa95532_0
  libmamba 1.5.1-hcd6fe79_0 --> 1.5.3-hcd6fe79_0
  libmambapy 1.5.1-py311h77c03ed_0 --> 1.5.3-py311h77c03ed_0
  openssl 3.0.11-h2bbff1b_2 --> 3.0.12-h2bbff1b_0
  urllib3 1.26.16-py311haa95532_0 --> 1.26.18-py311haa95532_0
  yaml-cpp 0.7.0-hd77b12b_1 --> 0.8.0-hd77b12b_0



Downloading and Extracting Packages: ...working... done
Preparing transaction: ...working... done
Verifying transaction: ...working... done
Executing transaction: ...working... done
 + "C:/Users/hp/AppData/Local/r-miniconda/condabin/conda.bat" "create" "--yes" "--name" "r-reticulate" "python=3.9" "numpy" " --quiet" "-c" "conda-forge"
Channels:
 -conda-forge
 -defaults
Platform: win-64
Collecting package metadata (repodata.json): ...working... done
Solving environment: ...working... done

## Package Plan ##

  environment location: C:\Users\hp\AppData\Local\R-MINI~1\envs\r-reticulate

  added/updated specs:
    - numpy
    -python=3.9


The following packages will be downloaded:

    package | build
    -------------------------------|-----------------
    bzip2-1.0.8 | hcfcfb64_5 122 KB conda-forge
    ca-certificates-2023.7.22 | h56e8100_0 146 KB conda-forge
    intel-openmp-2023.2.0 | h57928b3_50497 2.4 MB conda-forge
    libblas-3.9.0 | 19_win64_mkl 4.8 MB conda-forge
    libcblas-3.9.0 | 19_win64_mkl 4.8 MB conda-forge
    libffi-3.4.2 | h8ffe710_5 41 KB conda-forge
    libhwloc-2.9.3 |default_haede6df_1009 2.5 MB conda-forge
    libiconv-1.17 | h8ffe710_0 698 KB conda-forge
    liblapack-3.9.0 | 19_win64_mkl 4.8 MB conda-forge
    libsqlite-3.44.0 | hcfcfb64_0 833 KB conda-forge
    libxml2-2.11.5 | hc3477c8_1 1.5 MB conda-forge
    libzlib-1.2.13 | hcfcfb64_5 54 KB conda-forge
    mkl-2023.2.0 | h6a75c08_50496 138.0 MB conda-forge
    numpy-1.26.0 | py39hddb5d58_0 5.7 MB conda-forge
    openssl-3.1.4 | hcfcfb64_0 7.1 MB conda-forge
    pip-23.3.1 | pyhd8ed1ab_0 1.3 MB conda-forge
    pthreads-win32-2.9.1 | hfa6e2cd_3 141 KB conda-forge
    python-3.9.18 |h4de0772_0_cpython 16.1 MB conda-forge
    python_abi-3.9 | 4_cp39 7 KB conda-forge
    setuptools-68.2.2 | pyhd8ed1ab_0 454 KB conda-forge
    tbb-2021.10.0 | h91493d7_2 153 KB conda-forge
    tk-8.6.13 | h5226925_1 3.3 MB conda-forge
    tzdata-2023c | h71feb2d_0 115 KB conda-forge
    ucrt-10.0.22621.0 | h57928b3_0 1.2 MB conda-forge
    vc-14.3 | h64f974e_17 17 KB conda-forge
    vc14_runtime-14.36.32532 | hdcecf7f_17 722 KB conda-forge
    vs2015_runtime-14.36.32532 | h05e6639_17 17 KB conda-forge
    wheel-0.41.3 | pyhd8ed1ab_0 57 KB conda-forge
    xz-5.2.6 | h8d14728_0 213 KB conda-forge
    -------------------------------------------------- ----------
                                           Total: 197.1 MB

The following NEW packages will be INSTALLED:

  bzip2 conda-forge/win-64::bzip2-1.0.8-hcfcfb64_5
  ca-certificates conda-forge/win-64::ca-certificates-2023.7.22-h56e8100_0
  intel-openmp conda-forge/win-64::intel-openmp-2023.2.0-h57928b3_50497
  libblas conda-forge/win-64::libblas-3.9.0-19_win64_mkl
  libcblas conda-forge/win-64::libcblas-3.9.0-19_win64_mkl
  libffi conda-forge/win-64::libffi-3.4.2-h8ffe710_5
  libhwloc conda-forge/win-64::libhwloc-2.9.3-default_haede6df_1009
  libiconv conda-forge/win-64::libiconv-1.17-h8ffe710_0
  liblapack conda-forge/win-64::liblapack-3.9.0-19_win64_mkl
  libsqlite conda-forge/win-64::libsqlite-3.44.0-hcfcfb64_0
  libxml2 conda-forge/win-64::libxml2-2.11.5-hc3477c8_1
  libzlib conda-forge/win-64::libzlib-1.2.13-hcfcfb64_5
  mkl conda-forge/win-64::mkl-2023.2.0-h6a75c08_50496
  numpy conda-forge/win-64::numpy-1.26.0-py39hddb5d58_0
  openssl conda-forge/win-64::openssl-3.1.4-hcfcfb64_0
  pip conda-forge/noarch::pip-23.3.1-pyhd8ed1ab_0
  pthreads-win32 conda-forge/win-64::pthreads-win32-2.9.1-hfa6e2cd_3
  python conda-forge/win-64::python-3.9.18-h4de0772_0_cpython
  python_abi conda-forge/win-64::python_abi-3.9-4_cp39
  setuptools conda-forge/noarch::setuptools-68.2.2-pyhd8ed1ab_0
  tbb conda-forge/win-64::tbb-2021.10.0-h91493d7_2
  tk conda-forge/win-64::tk-8.6.13-h5226925_1
  tzdata conda-forge/noarch::tzdata-2023c-h71feb2d_0
  ucrt conda-forge/win-64::ucrt-10.0.22621.0-h57928b3_0
  vc conda-forge/win-64::vc-14.3-h64f974e_17
  vc14_runtime conda-forge/win-64::vc14_runtime-14.36.32532-hdcecf7f_17
  vs2015_runtime conda-forge/win-64::vs2015_runtime-14.36.32532-h05e6639_17
  wheel conda-forge/noarch::wheel-0.41.3-pyhd8ed1ab_0
  xz conda-forge/win-64::xz-5.2.6-h8d14728_0


Preparing transaction: ...working... done
Verifying transaction: ...working... done
Executing transaction: ...working... done
* Miniconda has been successfully installed at "C:/Users/hp/AppData/Local/r-miniconda".
[1] "C:/Users/hp/AppData/Local/r-miniconda"