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

FileNotFoundError: [Errno 2] No such file or directory #3345

Open
1 task done
Shui-meridian opened this issue Dec 9, 2024 · 3 comments
Open
1 task done

FileNotFoundError: [Errno 2] No such file or directory #3345

Shui-meridian opened this issue Dec 9, 2024 · 3 comments
Labels
🐛 bug Something isn't working

Comments

@Shui-meridian
Copy link

Shui-meridian commented Dec 9, 2024

Describe the bug

Hi,
When I try to use the command "pdm update".

I received a error :

FileNotFoundError: [Errno 2] No such file or directory: ~\\AppData\\Local\\pdm\\pdm\\Cache\\wheels\\........

And I try to use the "pdm chache clear" to fix it, and it didn't work.

And I found, there is no dictionary named "pdm" under "Local".

To reproduce

pdm update

Expected Behavior

use "pdm update"

Environment Information

PDM version:
  2.21.0
Python Interpreter:
****\python.exe (3.10)
Project Root:
****
Local Packages:
(empty)

{
  "implementation_name": "cpython",
  "implementation_version": "3.12.8",
  "os_name": "nt",
  "platform_machine": "AMD64",
  "platform_release": "11",
  "platform_system": "Windows",
  "platform_version": "10.0.26100",
  "python_full_version": "3.10.11",
  "platform_python_implementation": "CPython",
  "python_version": "3.10",
  "sys_platform": "win32"
}

Verbose Command Output

  ✖ Update *** 1.6.0 -> 1.6.0 failed
pdm.termui: Error occurs updating ***: 
Traceback (most recent call last):
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.2288.0_x64__qbz5n2kfra8p0\Lib\concurrent\futures\thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~\pipx\venvs\pdm\Lib\site-packages\pdm\installers\synchronizers.py", line 50, in update_candidate
    self.manager.overwrite(dist, can)
  File "~\pipx\venvs\pdm\Lib\site-packages\pdm\installers\manager.py", line 62, in overwrite
    installed = self.install(candidate)
                ^^^^^^^^^^^^^^^^^^^^^^^
  File "~\pipx\venvs\pdm\Lib\site-packages\pdm\installers\manager.py", line 32, in install
    dist_info = install_wheel(
                ^^^^^^^^^^^^^^
  File "~\pipx\venvs\pdm\Lib\site-packages\pdm\installers\installers.py", line 193, in install_wheel
    with WheelFile.open(wheel) as source:
         ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.2288.0_x64__qbz5n2kfra8p0\Lib\contextlib.py", line 137, in __enter__
    return next(self.gen)
           ^^^^^^^^^^^^^^
  File "~\pipx\venvs\pdm\Lib\site-packages\installer\sources.py", line 162, in open
    with zipfile.ZipFile(path) as f:
         ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.2288.0_x64__qbz5n2kfra8p0\Lib\zipfile\__init__.py", line 1331, in __init__
    self.fp = io.open(file, filemode)
              ^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '~\\AppData\\Local\\pdm\\pdm\\Cache\\wheels\\83\\b5\\d1\\*******.whl'
  Retry failed jobs(2/2)
pdm.termui: Overwriting distribution ***
  ✖ Update *** 1.6.0 -> 1.6.0 failed
pdm.termui: Error occurs updating ***: 
Traceback (most recent call last):
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.2288.0_x64__qbz5n2kfra8p0\Lib\concurrent\futures\thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~\pipx\venvs\pdm\Lib\site-packages\pdm\installers\synchronizers.py", line 50, in update_candidate
    self.manager.overwrite(dist, can)
  File "~\pipx\venvs\pdm\Lib\site-packages\pdm\installers\manager.py", line 62, in overwrite
    installed = self.install(candidate)
                ^^^^^^^^^^^^^^^^^^^^^^^
  File "~\pipx\venvs\pdm\Lib\site-packages\pdm\installers\manager.py", line 32, in install
    dist_info = install_wheel(
                ^^^^^^^^^^^^^^
  File "~\pipx\venvs\pdm\Lib\site-packages\pdm\installers\installers.py", line 193, in install_wheel
    with WheelFile.open(wheel) as source:
         ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.2288.0_x64__qbz5n2kfra8p0\Lib\contextlib.py", line 137, in __enter__
    return next(self.gen)
           ^^^^^^^^^^^^^^
  File "~\pipx\venvs\pdm\Lib\site-packages\installer\sources.py", line 162, in open
    with zipfile.ZipFile(path) as f:
         ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.2288.0_x64__qbz5n2kfra8p0\Lib\zipfile\__init__.py", line 1331, in __init__
    self.fp = io.open(file, filemode)
              ^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '~\\AppData\\Local\\pdm\\pdm\\Cache\\wheels\\83\\b5\\d1\\******.whl'
  ✖ Some package operations failed.
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "~\.local\bin\pdm.exe\__main__.py", line 7, in <module>
  File "~\pipx\venvs\pdm\Lib\site-packages\pdm\core.py", line 392, in main
    return core.main(args or sys.argv[1:])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~\pipx\venvs\pdm\Lib\site-packages\pdm\core.py", line 270, in main
    raise cast(Exception, err).with_traceback(traceback) from None
  File "~\pipx\venvs\pdm\Lib\site-packages\pdm\core.py", line 265, in main
    self.handle(project, options)
  File "~\pipx\venvs\pdm\Lib\site-packages\pdm\core.py", line 195, in handle
    command.handle(project, options)
  File "~\pipx\venvs\pdm\Lib\site-packages\pdm\cli\commands\update.py", line 75, in handle
    self.do_update(
  File "~\pipx\venvs\pdm\Lib\site-packages\pdm\cli\commands\update.py", line 200, in do_update
    do_sync(
  File "~\pipx\venvs\pdm\Lib\site-packages\pdm\cli\actions.py", line 301, in do_sync
    synchronizer.synchronize()
  File "~\pipx\venvs\pdm\Lib\site-packages\pdm\installers\synchronizers.py", line 226, in synchronize
    raise InstallationError("Some package operations failed.")
pdm.exceptions.InstallationError: Some package operations failed.

Additional Context

No response

Are you willing to submit a PR to fix this bug?

  • Yes, I would like to submit a PR.
@Shui-meridian Shui-meridian added the 🐛 bug Something isn't working label Dec 9, 2024
@frostming
Copy link
Collaborator

I don't know how to reproduce it because I can't (on MacOS)

@Shui-meridian
Copy link
Author

I don't know how to reproduce it because I can't (on MacOS)

It seems that PDM uses some mechanism to cache downloaded packages. From the error message, it can be seen that PDM tried to use the cached package, but did not find it in the corresponding location. This may be due to some reasons, such as version update causing caching. The folder has changed, for example I accidentally deleted the cache folder.

So one of the solutions I can think of, is to clear the cached mapping of the pdm record. But no matter if I try to reinstall pdm or something else, I can't do it to refresh the record. (I use PIPX). If I could know, Where does PDM read cache records and clear it, maybe the problem will be solved

@frostming
Copy link
Collaborator

is to clear the cached mapping of the pdm record

There is no such mapping, we just map the cache key to the file path under cache folder

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

No branches or pull requests

2 participants