Skip to content

UnicodeError under Windows if project has Unicode chars in path name #989

@DervishD

Description

@DervishD

When using the Python view on the sidebar, going to "PYTHON PROJECTS", one can expand the view to see packages installed on the current virtual environment:

Image

In my case, there are a LOT of missing packages, and the reason is this: the path name of the workspace (the Python project) has an Unicode char which can't be mapped and causes an UnicodeError, so the package does not get listed.

The problem does not happen if setting PYTHONIOENCODING=utf-8 before launching VSCode, but I don't know why it does not happen for the first packages (astroid, colorama, isort, etc.). In fact I was not expecting this to happen at all, needing the PYTHONIOENCODING trick.

I've included the partial output, with a test workspace with an Unicode diamond for testing purposes, but happens with other Unicode characters.

2025-11-14 21:39:15.933 [info] Running: C:\Users\rauln\Desktop\◆\legion\.venv\Scripts\python.exe -m pip list
2025-11-14 21:39:17.003 [info] python: Package      Version Editable project location

2025-11-14 21:39:17.004 [info] python: ------------ ------- -------------------------------

2025-11-14 21:39:17.005 [info] python: astroid      4.0.1

2025-11-14 21:39:17.006 [info] python: colorama     0.4.6
dill         0.4.0

2025-11-14 21:39:17.007 [info] python: isort        7.0.0

2025-11-14 21:39:17.007 [info] python: --- Logging error ---

2025-11-14 21:39:17.014 [info] python: Traceback (most recent call last):

2025-11-14 21:39:17.019 [info] python:   File "C:\Users\rauln\Desktop\\u25c6\legion\.venv\Lib\site-packages\pip\_internal\utils\logging.py", line 198, in emit
    self.console.print(renderable, overflow="ignore", crop=False, style=style)
    ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\rauln\Desktop\\u25c6\legion\.venv\Lib\site-packages\pip\_vendor\rich\console.py", line 1697, in print
    with self:
         ^^^^
  File "C:\Users\rauln\Desktop\\u25c6\legion\.venv\Lib\site-packages\pip\_vendor\rich\console.py", line 870, in __exit__
    self._exit_buffer()
    ~~~~~~~~~~~~~~~~~^^
  File "C:\Users\rauln\Desktop\\u25c6\legion\.venv\Lib\site-packages\pip\_vendor\rich\console.py", line 826, in _exit_buffer
    self._check_buffer()
    ~~~~~~~~~~~~~~~~~~^^
  File "C:\Users\rauln\Desktop\\u25c6\legion\.venv\Lib\site-packages\pip\_vendor\rich\console.py", line 2038, in _check_buffer
    self._write_buffer()
    ~~~~~~~~~~~~~~~~~~^^
  File "C:\Users\rauln\Desktop\\u25c6\legion\.venv\Lib\site-packages\pip\_vendor\rich\console.py", line 2074, in _write_buffer
    legacy_windows_render(buffer, LegacyWindowsTerm(self.file))
    ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\rauln\Desktop\\u25c6\legion\.venv\Lib\site-packages\pip\_vendor\rich\_windows_renderer.py", line 19, in legacy_windows_render
    term.write_text(text)
    ~~~~~~~~~~~~~~~^^^^^^
  File "C:\Users\rauln\Desktop\\u25c6\legion\.venv\Lib\site-packages\pip\_vendor\rich\_win32_console.py", line 402, in write_text
    self.write(text)
    ~~~~~~~~~~^^^^^^
  File "C:\Users\rauln\AppData\Local\Python\pythoncore-3.14-64\Lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
           ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeEncodeError: 'charmap' codec can't encode character '\u25c6' in position 44: character maps to <undefined>
Call stack:

2025-11-14 21:39:17.024 [info] python:   File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\rauln\Desktop\\u25c6\legion\.venv\Lib\site-packages\pip\__main__.py", line 24, in <module>
    sys.exit(_main())
  File "C:\Users\rauln\Desktop\\u25c6\legion\.venv\Lib\site-packages\pip\_internal\cli\main.py", line 80, in main
    return command.main(cmd_args)
  File "C:\Users\rauln\Desktop\\u25c6\legion\.venv\Lib\site-packages\pip\_internal\cli\base_command.py", line 159, in main
    return self._main(args)
  File "C:\Users\rauln\Desktop\\u25c6\legion\.venv\Lib\site-packages\pip\_internal\cli\base_command.py", line 238, in _main
    return self._run_wrapper(level_number, options, args)
  File "C:\Users\rauln\Desktop\\u25c6\legion\.venv\Lib\site-packages\pip\_internal\cli\base_command.py", line 107, in _run_wrapper
    status = _inner_run()
  File "C:\Users\rauln\Desktop\\u25c6\legion\.venv\Lib\site-packages\pip\_internal\cli\base_command.py", line 98, in _inner_run
    return self.run(options, args)
  File "C:\Users\rauln\Desktop\\u25c6\legion\.venv\Lib\site-packages\pip\_internal\commands\list.py", line 206, in run
    self.output_package_listing(packages, options)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions