-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Missing " get_installed_distributions() " attribute in module " pip " #5243
Comments
See https://pip.pypa.io/en/latest/user_guide/#using-pip-from-your-program - importing functions from pip is not supported. In this case, setuptools (specifically pkg_resources) probably has the functionality you need. |
This comment has been minimized.
This comment has been minimized.
@codingCoffee No, that's explicitly not the right thing to do. Please don't do this, we will not support such usage. |
@pfmoore, I agree, that it's a bad practice. I just meant the comment as a quick fix to the problem |
@08zhangyi thats horrible - pip has json output for that which gives correct parsed results, please edit/remove the bad code @codingCoffee same for your bad example - because people do actually use bad examples because they are the first thing they find that works |
Hi @Great-Li-Xin! You can use import pkg_resources
dists = [d for d in pkg_resources.working_set]
# Filter out distributions you don't care about and use. The function @codingCoffee mentioned has moved into an @08zhangyi that seems to be a very fragile way to do this. As @RonnyPfannschmidt points out, there's JSON output @Great-Li-Xin feel free to close this issue if your concerns are addressed. :) |
@pradyunsg , thank you! I have deleted my answer and changed my code as you say. |
From pip 10.0.0 on pip.get_installed_distributions does not work any more. I suggest to use pkg_resources.working_set instead as discussed here: pypa/pip#5243. Works fine for me...
As discussed in this thread: pypa/pip#5243 use of the functions inside pip._internal is strongly discouraged. As such I have replaced this functions usage with the pip maintainers recommended solution.
This comment has been minimized.
This comment has been minimized.
To restate, this function has moved into |
Downgrade pip to 9.0.3 will fix this problem
|
@Yemsheng Downgrading to pip 9.0.3 is a way to work around this issue; you're essentially pinning yourself to an older version of pip until the underlying project changes itself to use a supported way to perform these actions. |
pip 10 moved several interfaces to an internal package, causing our pyversion.py script to fail. This patches fixes the issue by getting installed distributions directly from setuptools, as suggested in pypa/pip#5243. See merge request core/dune-common!540 (cherry picked from commit 746aa62) 2443bc4 Make Python package detection work with pip 10
pip.get_installed_distributions() is in internal function that was never meant to be externally called and has since been locked out by external functions. Lets switch over to the supported function in setuptools pkg_resources.get_distribution() to search the installed packages. See: pypa/pip#5243 Fixes: 255
pip.get_installed_distributions() is in internal function that was never meant to be externally called and has since been locked out by external functions. Lets switch over to the supported function in setuptools pkg_resources.get_distribution() to search the installed packages. See: pypa/pip#5243 Fixes: DataSploit#255
well i believe the suggested solution is best for me import pkg_resources dists = [d for d in pkg_resources.working_set] |
pip.get_installed_distributions() is in internal function that was never meant to be externally called and has since been locked out by external functions. Lets switch over to the supported function in setuptools pkg_resources.get_distribution() to search the installed packages. See: pypa/pip#5243 Fixes: DataSploit#255
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Description:
for dist in pip.get_installed_distributions():
AttributeError: 'module' object has no attribute 'get_installed_distributions'
What I've run:
The text was updated successfully, but these errors were encountered: