Repository: iterative/dvc

Issue:
status: cannot import name 'shellcon' from win32com.shell (unknown location)
# Bug Report

## `status`: `cannot import name 'shellcon' from win32com.shell (unknown location)`

This issue causes fatal errors in multiple commands and subcommands, including `status`, `exp`, `list`, `queue` and perhaps most crucially - `doctor`. I have not assembled an exhaustive list of affected commands. Very few commands can be run from recent versions of DVC (more context below).

### Reproduce
I have successfully reproduced the issue using DVC's example project:
```console
git clone https://github.com/iterative/example-get-started.git
cd example-get-started
dvc status --verbose
```

Output:

```console
2023-03-07 10:18:22,138 DEBUG: v2.46.0 (exe), CPython 3.10.10 on Windows-10-10.0.19044-SP0
2023-03-07 10:18:22,138 DEBUG: command: status --verbose
2023-03-07 10:18:22,356 ERROR: unexpected error - cannot import name 'shellcon' from 'win32com.shell' (unknown location)
Traceback (most recent call last):
  File "dvc\cli\__init__.py", line 209, in main
  File "dvc\cli\command.py", line 20, in __init__
  File "dvc\repo\__init__.py", line 208, in __init__
  File "dvc\config.py", line 116, in __init__
  File "dvc\config.py", line 162, in load
  File "dvc\config.py", line 294, in load_config_to_level
  File "funcy\objects.py", line 28, in __get__
  File "dvc\config.py", line 131, in files
  File "dvc\config.py", line 132, in <dictcomp>
  File "dvc\config.py", line 127, in get_dir
  File "appdirs.py", line 237, in site_config_dir
  File "appdirs.py", line 134, in site_data_dir
  File "appdirs.py", line 480, in _get_win_folder_with_pywin32
ImportError: cannot import name 'shellcon' from 'win32com.shell' (unknown location)

Traceback (most recent call last):
  File "dvc\cli\__init__.py", line 209, in main
  File "dvc\cli\command.py", line 20, in __init__
  File "dvc\repo\__init__.py", line 208, in __init__
  File "dvc\config.py", line 116, in __init__
  File "dvc\config.py", line 162, in load
  File "dvc\config.py", line 294, in load_config_to_level
  File "funcy\objects.py", line 28, in __get__
  File "dvc\config.py", line 131, in files
  File "dvc\config.py", line 132, in <dictcomp>
  File "dvc\config.py", line 127, in get_dir
  File "appdirs.py", line 237, in site_config_dir
  File "appdirs.py", line 134, in site_data_dir
  File "appdirs.py", line 480, in _get_win_folder_with_pywin32
ImportError: cannot import name 'shellcon' from 'win32com.shell' (unknown location)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "dvc\__main__.py", line 7, in <module>
  File "dvc\cli\__init__.py", line 236, in main
  File "dvc\cli\__init__.py", line 145, in _log_exceptions
  File "dvc\cli\__init__.py", line 47, in _log_unknown_exceptions
  File "dvc\info.py", line 38, in get_dvc_info
  File "dvc\repo\__init__.py", line 208, in __init__
  File "dvc\config.py", line 116, in __init__
  File "dvc\config.py", line 162, in load
  File "dvc\config.py", line 294, in load_config_to_level
  File "funcy\objects.py", line 28, in __get__
  File "dvc\config.py", line 131, in files
  File "dvc\config.py", line 132, in <dictcomp>
  File "dvc\config.py", line 127, in get_dir
  File "appdirs.py", line 237, in site_config_dir
  File "appdirs.py", line 134, in site_data_dir
  File "appdirs.py", line 480, in _get_win_folder_with_pywin32
ImportError: cannot import name 'shellcon' from 'win32com.shell' (unknown location)
[37132] Failed to execute script '__main__' due to unhandled exception!
```

### Expected

I expect DVC commands to execute successfully.

### Environment information

Windows 10 (not WSL), DVC v 2.46.0 (installed from GitHub releases page)

**Output of `dvc doctor`:**

```console
$ dvc doctor
ERROR: unexpected error - cannot import name 'shellcon' from 'win32com.shell' (unknown location)

Having any troubles? Hit us up at https://dvc.org/support, we are always happy to help!
Traceback (most recent call last):
  File "dvc\__main__.py", line 7, in <module>
  File "dvc\cli\__init__.py", line 241, in main
  File "dvc\analytics.py", line 50, in is_enabled
  File "dvc\config.py", line 116, in __init__
  File "dvc\config.py", line 162, in load
  File "dvc\config.py", line 294, in load_config_to_level
  File "funcy\objects.py", line 28, in __get__
  File "dvc\config.py", line 131, in files
  File "dvc\config.py", line 132, in <dictcomp>
  File "dvc\config.py", line 127, in get_dir
  File "appdirs.py", line 237, in site_config_dir
  File "appdirs.py", line 134, in site_data_dir
  File "appdirs.py", line 480, in _get_win_folder_with_pywin32
ImportError: cannot import name 'shellcon' from 'win32com.shell' (unknown location)
[32180] Failed to execute script '__main__' due to unhandled exception!

```

**Additional Information (if any):**

This issue began showing up when I upgraded DVC to a version >v2.43.4 (downgrading to this version fixes the issue). I cannot say with certainty which version introduced this bug, as I have not exhaustively tested DVC version-by-version to identify it.


Discussion:
Note that this is fixed in `platformdirs`. `appdirs` is deprecated.

Resolving patch:
diff --git a/dvc/config.py b/dvc/config.py
--- a/dvc/config.py
+++ b/dvc/config.py
@@ -117,7 +117,7 @@ def __init__(
 
     @classmethod
     def get_dir(cls, level):
-        from appdirs import site_config_dir, user_config_dir
+        from platformdirs import site_config_dir, user_config_dir
 
         assert level in ("global", "system")
 


Test patch: