rye icon indicating copy to clipboard operation
rye copied to clipboard

ImportError: cannot import name 'DEV_PKGS' from 'pip._internal.commands.freeze'

Open QuentinDstl opened this issue 1 year ago • 7 comments

Steps to Reproduce

I have the following error when trying rye sync on last rye version on my pc

C:\Users\xxx\xx\x>rye sync

Expected Result

sync all normaly

Actual Result

Reusing already existing virtualenv
Generating production lockfile: C:\Users\xxx\xx\x\requirements.lock
WARNING: the legacy dependency resolver is deprecated and will be removed in future versions of pip-tools. The default resolver will be changed to 'backtracking' in pip-tools 7.0.0. Specify --resolver=backtracking to silence this warning.
Generating dev lockfile: C:\Users\xxx\xx\x\requirements-dev.lock
WARNING: the legacy dependency resolver is deprecated and will be removed in future versions of pip-tools. The default resolver will be changed to 'backtracking' in pip-tools 7.0.0. Specify --resolver=backtracking to silence this warning.
Installing dependencies
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\xxx\.rye\pip-tools\[email protected]\Scripts\pip-sync.exe\__main__.py", line 4, in <module>
  File "C:\Users\xxx\.rye\pip-tools\[email protected]\Lib\site-packages\piptools\scripts\sync.py", line 16, in <module>
    from .. import sync
  File "C:\Users\xxx\.rye\pip-tools\[email protected]\Lib\site-packages\piptools\sync.py", line 11, in <module>
    from pip._internal.commands.freeze import DEV_PKGS
ImportError: cannot import name 'DEV_PKGS' from 'pip._internal.commands.freeze' (C:\Users\xxx\AppData\Local\Temp\.tmpu5eIsy\pip\_internal\commands\freeze.py)
error: Installation of dependencies failed

Version Info

rye version infos :

rye 0.27.0
commit: 0.27.0 (43ee4fce0 2024-02-26)
platform: windows (x86_64)
self-python: [email protected]
symlink support: true
uv enabled: false

Stacktrace

No response

QuentinDstl avatar Feb 28 '24 16:02 QuentinDstl

I couldn't reproduce this on my windows machine with 0.28.0 (main).

❯ rye --version
rye 0.28.0
commit: 0.27.0+8 (2111778b3 2024-02-28)
platform: windows (x86_64)
self-python: [email protected]
symlink support: false
uv enabled: false

I tried doing things like self installing it into my current environment, using a completely wiped home directory, using [email protected] and 3.11 internally, and pinning different versions for the project.

Are you able to reproduce this in a different windows environment?

cnpryer avatar Feb 28 '24 21:02 cnpryer

The warnings indicate it's using a very old pip tools version, is that a Windows thing? Rye should recreate C:\Users\xxx.rye\pip-tools\[email protected] if you remove it, so you could try that and see what happens.

bluss avatar Feb 28 '24 21:02 bluss

I used pip 23.2 (when running into this error) and are now using pip 24.0. @cnpryer I am not able to reproduce it in a different windows environment. @bluss I remove [email protected] but rye is not recreating it, I only have the following error msg :

C:\Users\xxx\xx\x\.venv\Scripts>rye sync        
Reusing already existing virtualenv
Generating production lockfile: C:\Users\xxx\xx\x\requirements.lock
error: could not write production lockfile for project

Caused by:
    0: unable to run pip-compile
    1: The system cannot find the file specified. (os error 2)

QuentinDstl avatar Feb 29 '24 10:02 QuentinDstl

@QuentinDstl Hm, ok that's confusing, not sure why it would happen like that. the intention was to remove exactly the C:\Users\xxx\.rye\pip-tools\[email protected] directory, and I can't see why that wouldn't trigger a reinstall of pip-tools (it does for me, platform: linux). Note it's about the pip-tools install which is separate from pip, separate version number etc.

bluss avatar Feb 29 '24 17:02 bluss

same issue. related https://github.com/astral-sh/rye/issues/368

isn't uv supposed to take over by now?

majidaldo avatar Mar 04 '24 23:03 majidaldo

same issue. related #368

isn't uv supposed to take over by now?

got further by reinstalling my rye. got the new resolvers.

majidaldo avatar Mar 04 '24 23:03 majidaldo

I will try to reinstall rye

QuentinDstl avatar Mar 05 '24 11:03 QuentinDstl

I am using MacBook Pro 2023 (Apple M2 Max) and am experiencing a similar issue.

Version of rye

rye 0.28.0
commit: 0.28.0 (2024-03-07)
platform: macos (aarch64)
self-python: [email protected]
symlink support: true
uv enabled: false

Error message

rye sync
Reusing already existing virtualenv
Generating production lockfile: /Users/keita-koga/gitrepos/my-project/requirements.lock
WARNING: the legacy dependency resolver is deprecated and will be removed in future versions of pip-tools. The default resolver will be changed to 'backtracking' in pip-tools 7.0.0. Specify --resolver=backtracking to silence this warning.
Generating dev lockfile: /Users/keita-koga/gitrepos/my-project/requirements-dev.lock
WARNING: the legacy dependency resolver is deprecated and will be removed in future versions of pip-tools. The default resolver will be changed to 'backtracking' in pip-tools 7.0.0. Specify --resolver=backtracking to silence this warning.
Installing dependencies
Traceback (most recent call last):
  File "/Users/keita-koga/.rye/pip-tools/[email protected]/bin/pip-sync", line 5, in <module>
    from piptools.scripts.sync import cli
  File "/Users/keita-koga/.rye/pip-tools/[email protected]/lib/python3.12/site-packages/piptools/scripts/sync.py", line 16, in <module>
    from .. import sync
  File "/Users/keita-koga/.rye/pip-tools/[email protected]/lib/python3.12/site-packages/piptools/sync.py", line 11, in <module>
    from pip._internal.commands.freeze import DEV_PKGS
ImportError: cannot import name 'DEV_PKGS' from 'pip._internal.commands.freeze' (/var/folders/f7/rc26hcc55bvdqd3xxqw7yj6m0000gp/T/.tmpVLkRIq/pip/_internal/commands/freeze.py)
error: Installation of dependencies failed
zsh: exit 1     rye sync

keitakn avatar Mar 08 '24 07:03 keitakn

I had the same error right after I updated from 0.27.0 to 0.28.0, but it worked by running the following command and reinstalling.

rm -r ~/.rye

koei-kaji avatar Mar 08 '24 11:03 koei-kaji

@koei-kaji

Thank you! I solved it in the way you suggested👍.

keitakn avatar Mar 08 '24 16:03 keitakn

Maybe fixed by #865? It ensures new pip-tools

bluss avatar Mar 10 '24 19:03 bluss

I had the same error right after I updated from 0.27.0 to 0.28.0, but it worked by running the following command and reinstalling.

rm -r ~/.rye

Needed remove only ~/.rye/pip-tools. And need not reinstall rye.

moeyashi avatar Mar 11 '24 01:03 moeyashi