pip
path_encoding
ai_generated
true
pip install fails with UnicodeDecodeError in virtualenv with Korean path
ID: pip/pip-install-nonascii-venv-path
85%Fix Rate
88%Confidence
4Evidence
2023-01-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 23 | active | — | — | — |
Root Cause
pip install fails when virtualenv is created inside a directory with Korean characters and locale is not UTF-8.
genericWorkarounds
-
90% success Create virtualenv in an ASCII path and symlink or set VIRTUAL_ENV
python -m venv /opt/venvs/myproject && source /opt/venvs/myproject/bin/activate
-
92% success Set PYTHONUTF8=1 and ensure system locale is UTF-8 before creating venv
export PYTHONUTF8=1 LANG=ko_KR.UTF-8 && python -m venv ./venv && pip install -r requirements.txt
Sources: https://docs.python.org/3/using/cmdline.html#envvar-PYTHONUTF8
Dead Ends
Common approaches that don't work:
-
Recreate the virtualenv with --clear flag
90% fail
Recreating in the same Korean path will reproduce the same encoding error
-
Use pip install --no-cache-dir
85% fail
Cache is not the issue; the path encoding during extraction is the problem