A Persistent pip Error Bothered Me for a Long Time

~ pip3 install scapy
/usr/local/lib/python3.9/site-packages/pip/_internal/commands/install.py:230: UserWarning: Disabling all use of wheels due to the use of --build-option / --global-option / --install-option.
ERROR: Location-changing options found in --install-option: ['--prefix'] from command line. This is unsupported, use pip-level options like --user, --prefix, --root, and --target instead.

Sine an unknown time, pip (the package installer for Python) on my Mac started to produce errors like above for unknown reasons whenever I tried to do pip install.

There’s no answers at all on Google, and many attempts to reinstall Python 3 for fixing this have failed. From what it said, I thought that it may be related to some install options defined globally, because only in this way can pip still be affected even after I reinstalled it. I checked ~/.bash_profile and ~/.zshrc but found nothing regarding this thing.

Serendipitously, I ran pip3 with no arguments and saw this little option:

--isolated         Run pip in an isolated mode, ignoring environment variables and user configuration.

I tried to run pip3 --isolated install scapy. Surprisingly, it succeeded.

Then, I started to google where the “environment variables and user configuration” can be in, and I found the location for the pip configuration file is ~/.pip/pip.conf. When I opened the file, as expected, there’s a line with the “–prefix” option.

Therefore, to solve this issue, what we need to do is just to delete the line with the “–prefix” option in the pip configuration file and save the file.

After doing so, pip3 install can successfully run without the “–isolated” option, proving that it is right.

Today is a good day.