Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnicodeDecodeError in pdm 2.9.1 due to non-ASCII characters in .venv/pyvenv.cfg #2227

Closed
1 task done
k111s222 opened this issue Sep 4, 2023 · 0 comments · Fixed by j178/pdm#1
Closed
1 task done
Labels
🐛 bug Something isn't working

Comments

@k111s222
Copy link

k111s222 commented Sep 4, 2023

  • I have searched the issue tracker and believe that this is not a duplicate.

Note: This issue has been machine-translated. I apologize for any errors or lack of clarity.

  • When the directory name contains non-ASCII characters, the prompt field in .venv/pyvenv.cfg also contains non-ASCII values. This leads to a UnicodeDecodeError in pdm version 2.9.1.

  • It seems that specifying the encoding as utf-8 in line 58 of src/pdm/models/venv.py while using open() might solve the issue.

Steps to reproduce

pip uninstall pdm
pip install pdm

pdm init
pdm add numpy
(on non ascii directory)

STATUS: Resolving dependencies
pdm.termui: ======== Start resolving requirements ========
pdm.termui:   numpy>=1.25.2
pdm.termui:   python>=3.11
pdm.termui:   Adding requirement numpy>=1.25.2
pdm.termui:   Adding requirement python>=3.11
pdm.termui: ======== Starting round 0 ========
STATUS: Resolving: new pin python>=3.11
pdm.termui: Pinning: python None
pdm.termui: ======== Ending round 0 ========
pdm.termui: ======== Starting round 1 ========
STATUS: Resolving: new pin numpy 1.25.2
pdm.termui: Pinning: numpy 1.25.2
pdm.termui: ======== Ending round 1 ========
pdm.termui: ======== Starting round 2 ========
pdm.termui: ======== Resolution Result ========
pdm.termui: Stable pins:
pdm.termui:   python None
pdm.termui:    numpy 1.25.2
STATUS: Fetching hashes for resolved packages...
pdm.termui: Fetching hashes for [email protected]
🔒 Lock successful
STATUS: Resolving packages from lockfile...
STATUS: Fetching hashes for resolved packages...
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "D:\pybin\python3.11.4\Scripts\pdm.exe\__main__.py", line 7, in <module>
  File "D:\pybin\python3.11.4\Lib\site-packages\pdm\core.py", line 290, in main
    return Core().main(args or sys.argv[1:])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\pybin\python3.11.4\Lib\site-packages\pdm\core.py", line 208, in main
    raise cast(Exception, err).with_traceback(traceback) from None
  File "D:\pybin\python3.11.4\Lib\site-packages\pdm\core.py", line 203, in main
    self.handle(project, options)
  File "D:\pybin\python3.11.4\Lib\site-packages\pdm\core.py", line 157, in handle
    command.handle(project, options)
  File "D:\pybin\python3.11.4\Lib\site-packages\pdm\cli\commands\update.py", line 71, in handle
    self.do_update(
  File "D:\pybin\python3.11.4\Lib\site-packages\pdm\cli\commands\update.py", line 182, in do_update
    do_sync(
  File "D:\pybin\python3.11.4\Lib\site-packages\pdm\cli\actions.py", line 200, in do_sync
    synchronizer = project.core.synchronizer_class(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\pybin\python3.11.4\Lib\site-packages\pdm\installers\synchronizers.py", line 131, in __init__
    self.working_set = environment.get_working_set()
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\pybin\python3.11.4\Lib\site-packages\pdm\environments\python.py", line 50, in get_working_set
    if venv is not None and venv.include_system_site_packages:
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\pybin\python3.11.4\Lib\site-packages\pdm\models\venv.py", line 71, in include_system_site_packages
    return self.venv_config.get("include-system-site-packages") == "true"
           ^^^^^^^^^^^^^^^^
  File "D:\pybin\python3.11.4\Lib\functools.py", line 1001, in __get__
    val = self.func(instance)
          ^^^^^^^^^^^^^^^^^^^
  File "D:\pybin\python3.11.4\Lib\site-packages\pdm\models\venv.py", line 59, in venv_config
    for line in fp:
UnicodeDecodeError: 'cp949' codec can't decode byte 0xeb in position 295: illegal multibyte sequence

Environment Information

PDM version:
  2.9.1

PS E:\004.CODE_MAIN\테스트s\testpmd_논아스키> pdm info --env
{
  "implementation_name": "cpython",
  "implementation_version": "3.11.4",
  "os_name": "nt",
  "platform_machine": "AMD64",
  "platform_release": "10",
  "platform_system": "Windows",
  "platform_version": "10.0.19045",
  "python_full_version": "3.11.4",
  "platform_python_implementation": "CPython",
  "python_version": "3.11",
  "sys_platform": "win32"
}
@k111s222 k111s222 added the 🐛 bug Something isn't working label Sep 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant