You are using pip3 to install flask-script which is associated with python 3.5. However, you are trying to upgrade pip associated with the python 2.7, try running pip3 install --upgrade pip.

It might be a good idea to take some time and read about virtual environments in Python. It isn't a best practice to install all of your packages to the base python installation. This would be a good start: http://docs.python-guide.org/en/latest/dev/virtualenvs/

Answer from JanHak on Stack Overflow
🌐
Note.nkmk.me
note.nkmk.me › home › python
How to Use pip (Install, Update, Uninstall Packages) | note.nkmk.me
April 18, 2025 - $ pip install --upgrade <package-name> ... package, using the following command. ... For pip2 or pip3 commands, replace the first pip with pip2 or pip3....
🌐
freeCodeCamp
freecodecamp.org › news › pip-upgrade-and-how-to-update-pip-and-python
Pip Upgrade – And How to Update Pip and Python
March 14, 2023 - In cases when you want to update only Pip, open your terminal and run pip3 install --upgrade pip.
🌐
ActiveState
activestate.com › resources › quick-reads › how-to-update-all-python-packages
Secure Python Packages Built From Source | ActiveState
Vetted Python packages delivered as native Wheels through pip and your existing artifact repositories. Built from source, continuously remediated, SLA-backed.
🌐
Squash
squash.io › how-to-upgrade-pip3-in-python
How to Upgrade Pip3 in Python - Squash Labs
November 2, 2023 - A guide on upgrading Pip3, the Python package installer.
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-upgrade-pip-and-python-on-windows-linux-and-macos
How to Upgrade Pip and Python on Windows, Linux, and MacOS? - GeeksforGeeks
January 30, 2026 - pip3 install --upgrade pip · Option 1: Using Homebrew (Recommended) brew update brew upgrade python · Option 2: Manual Download · Visit the Python Downloads Page for macOS · Download the latest .pkg installer.
🌐
Wikihow
wikihow.com › computers and electronics › software › programming › python › how to update pip on windows, mac, & linux: easy tutorial
How to Update Pip on Windows, Mac, & Linux: Easy Tutorial
April 8, 2025 - If you're using Python 3.4 or later, you can update Pip using the command python -m pip install --upgrade pip. To check your Pip version, use pip3 -V (Python 3) or pip2 -V (Python 2).
Find elsewhere
🌐
pip
pip.pypa.io › en › stable › installation
Installation - pip documentation v26.1.2
Upgrade your pip by running: Linux · $ python -m pip install --upgrade pip MacOS · $ python -m pip install --upgrade pip Windows · C:> py -m pip install --upgrade pip · The current version of pip works on: Windows, Linux and macOS. CPython 3.10, 3.11, 3.12, 3.13, 3.14 and latest PyPy3.
🌐
Codedamn
codedamn.com › news › python
How to Update Pip and Python On Your System With Pip Upgrade
June 22, 2023 - This will update your Pip version to the latest available. To verify the updated version, run pip --version or pip3 --version, depending on the version you installed.
🌐
MTU Service Desk
servicedesk.mtu.edu › TDClient › 1801 › Portal › KB › PrintArticle
Installing, uninstalling, or upgrading Python modules using Pip (Linux)
Python modules are packages, or modules, which can be imported into a project to use. This includes packages like matplotlib, numpy, flask, and many more. You can install and uninstall packages for Python with the Pip package manager. Python modules that are stored on your home drive will only ...
🌐
DreamHost
help.dreamhost.com › hc › en-us › articles › 115000699011-Using-pip3-to-install-Python3-modules
Using pip3 to install Python3 modules – DreamHost Knowledge Base
[server]$ python3 -m pip install --upgrade pip [server]$ pip3 --version pip 18.1 from /home/username/opt/python-3.6.2/lib/python3.6/site-packages/pip (python 3.6)
🌐
River
river.me › blog › change-pip-version
Update pip/pip3 to Python 3.8 in Ubuntu – River Writes - A MediaWiki Blog
April 11, 2021 - How to update the pip/pip3 commands in Ubuntu so they use Python3.8 rather than Python3.5
🌐
MonoVM
monovm.com › blog › tutorials › how to upgrade pip package to latest version [pip update]
How to Upgrade Pip Package to Latest Version [Pip Update]
January 30, 2024 - How to Upgrade PIP Package to Latest Version [PIP Update] in Windows, Linux, and Mac operating systems to its latest version, then you are at the correct blog to start with your journey.
🌐
BitLaunch
bitlaunch.io › blog › how-to-upgrade-pip
How to upgrade your pip package to the latest version
December 20, 2025 - pip3 install --upgrade matplotlib · That about covers it. Pip is a versatile and useful tool and know you should now understand it a little better. If you like to do your development in the cloud, feel free to check out our high-speed, anonymous ...
🌐
Code2care
code2care.org › home › python › how to upgrade pip/pip3 package installer for python
How to upgrade pip/pip3 package installer for Python | Code2care
January 26, 2026 - % pip3 install --upgrade pip --user Collecting pip Using cached https://files.pythonhosted.org/packages/47/ca/d/pip-21.1.3-py3-none-any.whl Installing collected packages: pip Successfully installed pip-21.1.3
🌐
Python.org
discuss.python.org › packaging
Ways to update pip (and when updating is a good idea) - Packaging - Discussions on Python.org
May 23, 2024 - Off-topic question from a pip maintainer here - why isn’t pip’s self check message enough to tell users to keep their copy of pip up to date? We don’t support anything but the latest version of pip, so it’s important to us that people get the message about keeping their copy of pip ...
🌐
DataCamp
datacamp.com › tutorial › pip-upgrade-python
How to Upgrade Pip and Python in Windows, MacOS, and Linux | DataCamp
December 23, 2025 - After downloading the latest Python version from the official Python website, locate the downloaded installer file and double-click to open it. In the installer window, ensure to check the "Add Python to PATH" option.
Top answer
1 of 1
4

First of all, pip and pipx are separate programs. pip is a general purpose Python package manager, it can work systemwide (I mean... it used to), or in a virtual environment. pipx focuses specifically on installing binaries (not libraries), and it works by creating an isolated virtual environment and running pip inside it.

--json and --include-injected are flags of pipx (specifically "pipx list"), not flags of pip. Your problem is that pipx is too old, not that pip is too old.

Ansible uses the flags here.

In order to upgrade pipx safely, you must find out how you originally installed it. Was it installed as a Debian package (with dpkg and/or apt), or was it installed manually with pip? Find its location, e.g.:

$ which pipx
/usr/bin/pipx

Check if dpkg recognizes that file and knows which Debian package it belongs to.

$ dpkg --search /usr/bin/pipx
pipx: /usr/bin/pipx

If you see that, great. Just do a normal system upgrade, and you'll get the new version. (This is unlikely because if it were so easy then you wouldn't even be asking this question.)

$ dpkg --search /usr/bin/pipx
dpkg-query: no path found matching pattern /usr/bin/pipx

If you see that, it means you previously installed it manually with sudo pip install pipx or similar, back when that was still allowed. In this case, your goal should be to completely uninstall the old pipx, along with any of its dependencies that were also installed manually, and then install the official Debian pipx package.

This command prints the Debian package owner of each file in /usr/lib/python*. Files which do not belong to any Debian package will print an error. Those errors will tell you the previously manually installed packages which probably need to be manually uninstalled.

$ find /usr/lib/python* -type f ! -name '*.pyc' -exec dpkg --search {} + 2>&1

I think the correct way to uninstall them is with sudo pip uninstall --break-system-packages pipx (and so on for other packages). In this case --break-system-packages should be fine because you're just cleaning up a mess that was created before the flag existed. BUT MAKE SURE you only uninstall packages which had the "no path found matching pattern" error. NOT the packages which are already recognized by dpkg.

When the command doesn't print any "no path found matching pattern" errors anymore, install the official Debian pipx package using sudo apt-get install pipx. If it works, you're done. If it prints any conflicts with existing files, the old pipx probably wasn't completely uninstalled.