If the package still shows up in pip freeze after you've uninstalled it, it indicates that there might be some residual files or multiple installations across different paths in your environment. Here are detailed steps to identify and fully remove all traces of the package:
Steps to Completely Remove the Package and Fix pip freeze
Locate All Installations of the Package:
Search your entire environment for any remnants of the package. This will help identify any stray files that pip uninstall may have missed:
bashCopyEditfind $(python -c "import site; print(site.getsitepackages()[0])") -name "package_name"
Also, search in user-specific installations:
bashCopyEditfind $(python -c "import site; print(site.getusersitepackages())") -name "package_name"
Check if any files or folders related to the package are found and manually delete them if necessary.
Check for Editable Installs (.egg-info or .pth Files):
Editable installs leave behind .egg-info or .pth files, which can cause the package to still appear in pip freeze. Check for these files:
bashCopyEditfind $(python -c "import site; print(site.getsitepackages()[0])") -name ".egg-info" -o -name ".pth"
Delete any that are related to the package.
Check if the Package is Installed by Conda:
If the package was installed by conda, pip might still detect it. Check using:
bashCopyEditconda list | grep package_name
If the package appears, remove it using:
bashCopyEditconda remove package_name
Clear pip’s Cache Again:
Clearing pip’s cache ensures that no cached versions are reinstalled:
bashCopyEditpip cache purge
Check site-packages Directory:
Inspect your site-packages directory manually to ensure there are no remaining package folders:
bashCopyEditls $(python -c "import site; print(site.getsitepackages()[0])")
Manually delete any folders related to the package.
Check pip freeze Output for Stray Entries:
Sometimes, pip freeze can display entries from requirements.txt or other files that are not directly linked to installed packages. Ensure you’re not seeing stale output from these sources.
Reinstall and Uninstall Again to Force Cleanup:
In some cases, forcibly reinstalling the package and then uninstalling it again can help clean up any lingering metadata:
bashCopyEditpip install --no-cache-dir package_name
pip uninstall package_name
Restart Your Environment:
After performing the above steps, restart your shell or Python environment to ensure no old paths or metadata are still being loaded.
These steps should fully clear out the package from your environment. If the package still appears in pip freeze, double-check any custom paths or Python environments that might be inadvertently used. Let me know how it goes or if you need further assistance!