jazzband / pip-tools

A set of tools to keep your pinned Python dependencies fresh.
https://pip-tools.rtfd.io
BSD 3-Clause "New" or "Revised" License
7.71k stars 611 forks source link

pip-sync crashes (and is uninstalled) on reinstall of `pip-tools` #2068

Closed mjsir911 closed 7 months ago

mjsir911 commented 7 months ago

Environment Versions

  1. OS Type windows / git-bash (mingw I think?)
  2. Python version: $ python -V Python 3.11.8 (in venv)
  3. pip version: $ pip --version pip 24.0
  4. pip-tools version: $ pip-sync --version pip-sync, version 7.4.1

Steps to replicate

  1. I have a lockfile with a non-latest version: pip-tools==7.3.0
  2. run pip-sync requirements.txt

Expected result

pip-tools is successfully ininstalled / reinstalled with the requested version

Actual result

Installing collected packages: pip-tools, cryptography
  Attempting uninstall: pip-tools
    Found existing installation: pip-tools 7.4.1
    Uninstalling pip-tools-7.4.1:
ERROR: Could not install packages due to an OSError: [WinError 32] The process cannot access the file because it is being used by another process: '...\\venv\\scripts\\pip-sync.exe'
Check the permissions.

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "...\venv\Scripts\pip-sync.exe\__main__.py", line 7, in <module>
  File "...\venv\Lib\site-packages\click\core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "...\venv\Lib\site-packages\click\core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "...\venv\Lib\site-packages\click\core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "...\venv\Lib\site-packages\click\core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "...\venv\Lib\site-packages\piptools\scripts\sync.py", line 145, in cli
  File "...\venv\Lib\site-packages\piptools\sync.py", line 263, in sync
  File "C:\tools\python\python311\Lib\subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['...\\venv\\Scripts\\python.exe', '-m', 'pip', 'install', '-r', 'C:\\Users\\MSIRAB~1\\AppData\\Local\\Temp\\tmpllt2ny7m']' returned non-zero exit status 1.
webknjaz commented 7 months ago

Ah.. Infamous windows file locks. Dunno if there's a solution for that.

atugushev commented 7 months ago

@mjsir911 you should try python -m piptools sync requirements.txt instead. See more details here https://snarky.ca/why-you-should-use-python-m-pip/

mjsir911 commented 7 months ago

you should try python -m piptools sync requirements.txt

Yup this does it! tyvm.