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

Fix error with pip _get_installed_distributions #1494

Merged

Conversation

Louis-Dupont
Copy link
Contributor

@Louis-Dupont Louis-Dupont commented Oct 3, 2023

What

Fixing an issue that many people faced, including me, due to using an internal pip function

  File "/home/louis.dupont/PycharmProjects/super-gradients/src/super_gradients/training/sg_trainer/sg_trainer.py", line 14, in <module>
    from piptools.scripts.sync import _get_installed_distributions
  File "/home/louis.dupont/.conda/envs/louis-dev/lib/python3.9/site-packages/piptools/scripts/sync.py", line 16, in <module>
    from .. import sync
  File "/home/louis.dupont/.conda/envs/louis-dev/lib/python3.9/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' (/home/louis.dupont/.conda/envs/louis-dev/lib/python3.9/site-packages/pip/_internal/commands/freeze.py)

Associated issue

#1459

Solution

replacing _get_installed_distributions with a custom function get_installed_packages that uses pkg_resources instead.

At the same time, this new function allows us to have a dictionary of (lib -> version) which is better than a list (see below)

Before

['super-gradients 3.0.7+master',
 'widgetsnbextension 3.6.1',
 'webencodings 0.5.1',
 'wandb 0.13.1',
 'urllib3 1.26.11',
 'traitlets 5.3.0',
 'tornado 6.2',
 'tinycss2 1.1.1',
 'terminado 0.15.0',
 'stack-data 0.3.0',
 'soupsieve 2.3.2.post1',
 'smmap 5.0.0',
 'shortuuid 1.0.9',
 'setproctitle 1.3.2',
 'sentry-sdk 1.9.4',
 'Send2Trash 1.8.0',
 'scitokens 1.7.0',

After

{
    "super-gradients": "3.0.7+master",
    "pyzmq": "23.2.0",
    "argon2-cffi": "21.3.0",
    "argon2-cffi-bindings": "21.2.0",
    "ipython": "8.4.0",
    "ipywidgets": "7.7.1",
    "jupyter-client": "7.3.4",
    "ipykernel": "6.15.1",
    "nbconvert": "6.5.0",
    "notebook": "6.4.12",
    "jupyter-console": "6.4.4",
    "tornado": "6.2",
    "nbformat": "5.4.0",
    "qtconsole": "5.3.1",
}

@Louis-Dupont Louis-Dupont changed the title Fix conflict with pip Fix error with pip _get_installed_distributions Oct 3, 2023
@Louis-Dupont Louis-Dupont marked this pull request as ready for review October 3, 2023 08:57
Copy link
Collaborator

@BloodAxe BloodAxe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@BloodAxe BloodAxe merged commit 98f3226 into master Oct 3, 2023
7 checks passed
@BloodAxe BloodAxe deleted the hotfix/SG-000-fix_installed_package_detection_with_pip branch October 3, 2023 10:00
Louis-Dupont added a commit that referenced this pull request Oct 3, 2023
BloodAxe pushed a commit that referenced this pull request Oct 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants