WARNING: pip is being invoked by an old script wrapper Fix
In this tutorial, you'll learn about WARNING: pip is being invoked by an old script wrapper Fix. We cover key concepts, practical examples, and best practices.
Pip shows WARNING: pip is being invoked by an old script wrapper when the pip command is a legacy wrapper that does not point to the actual pip installation.
The Wrong Way
pip install requests
This shows:
WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
The Right Way
Use the module invocation instead:
python3 -m pip install requests
Step-by-Step Fix
1. Use python -m pip
# Instead of: pip install requests
python3 -m pip install requests
2. Locate and fix the pip wrapper
which pip
# /usr/local/bin/pip
file /usr/local/bin/pip
# /usr/local/bin/pip: Python script, ASCII text executable
# Edit the pip script or reinstall pip
python3 -m pip install --upgrade --force-reinstall pip
3. Reinstall pip completely
python3 -m pip install --upgrade pip
hash -r # refresh command hash
pip install requests # should now work without warning
4. Check for multiple Python installations
which python3
which pip
python3 -m pip --version
pip --version
# If versions differ, use python3 -m pip consistently
Prevention Tips
- Always use
python3 -m pipinstead of the barepipcommand. - Avoid using system package managers (
apt,yum) to install pip packages. - Reinstall pip after upgrading Python.
- Use virtual environments to isolate pip versions.
- Run
hash -rafter reinstalling pip to clear the command cache.
Common Mistakes with pip internals
- Using
headandtailinstead of pattern matching, causing runtime errors on empty lists - Forgetting that lazy evaluation defers computation until the value is forced, causing space leaks with unevaluated thunks
- Using
returnto exit a function early instead of wrapping a pure value in the monad
These mistakes appear frequently in real-world PYTHON code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.
Practice Exercise
Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.
This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.
FAQ
Built by the developers of Doda Browser, DodaZIP, and Durga Antivirus Pro.
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro