WARNING: Ignoring invalid distribution -ip (c:\python310\lib\site-packages)

avatar
Borislav Hadzhiev

Last updated: Apr 10, 2024
3 min

banner

# WARNING: Ignoring invalid distribution -ip (c:\python310\lib\site-packages)

The "WARNING: Ignoring invalid distribution -ip (c:\python310\lib\site-packages)" message is shown when there are partially installed or uninstalled packages in your site-packages directory.

To resolve the issue, open the lib\site-packages directory from the warning message and delete all folders with names starting with a tilde ~ symbol.

shell
WARNING: Ignoring invalid distribution - (c:\python310\lib\site-packages) WARNING: Ignoring invalid distribution -ip (c:\python310\lib\site-packages)
First, look at your warning message as it should contain a path to the lib\site-packages directory where the issue occurred, e.g. c:\python310\lib\site-packages (might be different for you).

Open the path in Explorer and order the folders by name by clicking on the Name column.

order site packages folder by name

The folders whose names start with a tilde ~ symbol are partially installed/uninstalled packages for which the installation process didn't finish successfully.

Select all folders that start with a tilde ~ symbol and delete them.

If you'd rather do this using the terminal, use the commands that correspond to your shell.

The article shows examples of how to do this using PowerShell, Command Prompt and bash.

# Delete all folders in site-packages starting with tilde ~ using PowerShell

To open PowerShell in your site-packages directory:

  1. Open the folder in a window.
  2. Press Shift and right-click in Explorer.

open powershell window in site packages folder

  1. Click on "Open PowerShell window here".
PowerShell
# โ›”๏ธ Make sure your shell is in your site-packages directory # ๐Ÿ‘‡๏ธ List all folders that start with a tilde ~ symbol ls ~*
  1. Only run the next command if the output of the ls ~* produces the expected results.

Run the following command to delete all folders starting with a tilde ~ symbol.

PowerShell
rm -Recurse ~*

powershell delete folders starting with tilde

# Delete all folders in site-packages starting with tilde ~ using CMD

If you use Command Prompt (CMD) on Windows:

  1. Navigate to your site-packages directory and list all folders that start with a tilde ~ symbol.
CMD
# ๐Ÿ‘‡๏ธ Navigate to your `site-packages` folder cd c:\path\to\site-packages # ๐Ÿ‘‡๏ธ List all folders that start with a tilde ~ symbol dir ~*
  1. Only run the next command if the output of the dir ~* produces the expected results.

Run the following command to delete all folders starting with a tilde ~ symbol.

CMD
# ๐Ÿ‘‡๏ธ Delete all folders starting with tilde ~ symbol for /f %i in ('dir /a:d /s /b ~*') do rd /s /q %i

cmd delete folders starting with tilde

# Delete all folders in site-packages starting with tilde ~ using Bash

If you use Bash shell:

  1. Navigate to your site-packages directory and list all folders that start with a tilde ~ symbol.
bash
# ๐Ÿ‘‡๏ธ List all folders that start with a tilde ~ symbol ls -d ~*

bash list all folders starting with tilde

  1. Only run the next command if the output of the ls -d ~* produces the expected results.

Run the following command to delete all folders starting with a tilde ~ symbol.

bash
rm -rf ~*

bash delete all folders starting with tilde

# If your warning message contains a folder name, make sure to delete it

If your error message contains a package name after the word distribution, e.g. "WARNING: Ignoring invalid distribution -ip C:\path\to\site-packages", you have to delete the specified folder from your site-packages directory - in the example the -ip directory.

Make sure to delete all folders starting with the specified prefix, e.g. -ip48128 and ~ip.

Similarly, if your error message starts with "WARNING: Ignoring invalid distribution -jango", then you have to delete the jango folder from your site-packages directory.

# Upgrade your version of pip

If you still get the warning message when installing or upgrading pip packages, upgrade your version of pip by running the following command.

shell
# ๐Ÿ‘‡๏ธ On Linux or macOS python -m ensurepip --upgrade # ๐Ÿ‘‡๏ธ Using python 3 python3 -m ensurepip --upgrade # ๐Ÿ‘‡๏ธ On Windows py -m ensurepip --upgrade
The ensurepip package enables us to bootstrap the pip installer into an existing Python installation or virtual environment.

Alternatively, you can use the official get-pip script to install pip.

Download the script from https://bootstrap.pypa.io/get-pip.py by:

  1. Clicking on the link.
  2. Right-clicking and selecting "Save as" in your browser.
Open your terminal in the location where the get-pip.py file is downloaded and run the following command.
shell
# ๐Ÿ‘‡๏ธ On Linux or macOS python get-pip.py # ๐Ÿ‘‡๏ธ Using python 3 python3 get-pip.py # ๐Ÿ‘‡๏ธ On Windows py get-pip.py

The get-pip.py script uses bootstrapping logic to install pip.

You can also download the script using curl (if you have curl installed).
shell
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py # ๐Ÿ‘‡๏ธ On Linux or macOS python get-pip.py --force-reinstall # ๐Ÿ‘‡๏ธ Using python 3 python3 get-pip.py --force-reinstall # ๐Ÿ‘‡๏ธ On Windows py get-pip.py --force-reinstall

The --force-reinstall option forces pip to reinstall the package.

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.

Copyright ยฉ 2024 Borislav Hadzhiev