QGIS Flatpak: No Module Named pip (Solved)
Published Updated
Run pip through the Flatpak with --devel, and install with --user. Both flags earn their place: --devel swaps the runtime for the SDK, where pip actually lives, and --user sends the files to a directory the sandbox lets you write to.
/usr/bin/python3: No module named pip
bwrap: execvp pip3: No such file or directory
ERROR: Could not install packages due to an EnvironmentError:
[Errno 30] Read-only file system: '/usr/lib/python3.11/site-packages/urllib3-1.25.9.dist-info'
error: runtime/org.kde.Sdk/x86_64/5.15-22.08 not installed
All four lines come from the same sandbox. You meet them on the Flathub QGIS package, org.qgis.qgis, on any Linux distribution, the moment a plugin asks for a Python package it cannot find and you reach for pip the way you would on any other install.
The quick fix
Read the SDK branch your QGIS Flatpak wants
Run flatpak info org.qgis.qgis and look at the Sdk: line. It gives a name and a branch, such as org.kde.Sdk/x86_64/6.10. Write the branch down. Don't copy the number from this page or from your error message: the branch moves with each QGIS release.
Install that exact branch
flatpak install flathub org.kde.Sdk//6.10, with the branch you just read after the double slash. Any other branch installs cleanly and still leaves you with no pip.
Install the package
flatpak run --devel --command=pip3 org.qgis.qgis install scipy --user
Swap scipy for whatever your plugin asks for. Keep both flags on every install you run from now on.
Check it worked
Restart QGIS, open Plugins, then Python Console, and type import scipy. A blank prompt back is the answer you want, because it means QGIS reads the folder you installed into and your plugin will find the package there too. A ModuleNotFoundError means the files landed somewhere QGIS never looks, whatever pip printed while it was working.
Fix 2: the files landed off the QGIS search path
Print the directory pip wrote to:
flatpak run --command=python3 org.qgis.qgis -c "import site; print(site.getusersitepackages())"
Compare it with sys.path in the QGIS Python Console. If that directory is not in the list, nothing installed there will ever import, however cleanly pip reported success. The install log looks perfect from top to bottom, and the package really is on disk, just outside the set of folders this Python reads when it starts.
If the error is unchanged, go to Fix 3.
Fix 3: the package compiles C extensions
You get a compiler error part way through the install, not a Python one. The SDK carries a compiler but not every development header, and you cannot hand it one from outside the sandbox. Tell pip to refuse a source build and take a prebuilt wheel instead:
flatpak run --devel --command=pip3 org.qgis.qgis install scipy --user --only-binary=:all:
If no wheel exists for your platform, look for a package that publishes one.
If the error is unchanged, go to Fix 4.
Fix 4: pip3 is still missing even with --devel
The SDK install did not take. Confirm the branch with flatpak list | grep Sdk, then build pip inside the sandbox as a fallback:
flatpak run --command=python3 org.qgis.qgis -m ensurepip --upgrade --user
Treat that as a fallback and nothing more. No source recommends it here, and with no --devel it runs against the Platform runtime rather than the SDK. Go back to step 3 of the quick fix afterwards.
If the error is unchanged, go to Fix 5.
Fix 5: you are not on the Flathub build
Check with flatpak info org.qgis.qgis. If that returns nothing, your QGIS came from somewhere else and none of the commands above apply to it. QGIS ships no official Snap package, so a Snap build is a third party's, with its own sandbox rules. On Debian and Ubuntu, install from the official QGIS repository instead of Flathub. QGIS then uses the system Python, and plugin dependencies install with ordinary pip.
If the error is unchanged, send it to me, and the section below says what to put in the mail.
Why it happens
The Flatpak carries its own Python, walled off from the one your distribution installed, so a package you added with the system pip or with apt is invisible to QGIS. Inside the sandbox, /usr is mounted read-only. A plain pip install tries to write there, which is the [Errno 30] line with the python3.11 path in it, and --user sends the same files to a writable directory instead.
Pip itself sits in the SDK, not in the runtime QGIS normally starts. Without --devel there is no pip3 to run at all, so the complaint comes from bwrap rather than from Python. And --devel only works when the matching SDK is already on your machine, which is what the last line of the error block is telling you.
Our AI Segmentation plugin spots a Flatpak QGIS and points you at Automatic mode, which runs on our servers and installs no Python package on your machine.
Still broken?
Send me three things: the version of your Flatpak QGIS from flatpak info org.qgis.qgis, the exact command you ran, and its full output rather than the last line of it. The address is stephane.barbot@terra-lab.ai. If the package you are chasing is one our AI Segmentation plugin asked for, say so in the mail, because that changes which of the five fixes above I look at first.
Questions people ask
Why does pip work in my terminal but not in QGIS?
Your terminal's pip belongs to the Python your distribution installed. The Flatpak has its own, and neither one can see the other's packages, so apt and system pip leave QGIS exactly where it was. Every install has to go through flatpak run, which is what puts it inside the sandbox.
Do I need --devel on every install?
Yes. pip3 sits in the SDK, not in the runtime QGIS starts, so without --devel there is nothing to run. Keep --user on every install too, or you are writing into a read-only /usr again and you get the [Errno 30] line back.
Where do the packages actually land?
In the per-user site directory inside the sandbox, which the command in Fix 2 prints for you. Check that path against sys.path in the QGIS Python Console. Files that sit outside every folder in that list are files QGIS will never import.
Is there an official QGIS Snap I could use instead?
No. snapcraft.io/qgis returns a 404, and the build in the Snap store is a third party's. The QGIS documentation lists Flatpak, distribution packages and Spack, so on Debian or Ubuntu the alternative to Flathub is the official QGIS repository, not Snap.
Once imports work you can get back to the plugins, and our two live on the QGIS AI hub. Windows has its own version of this problem, written up in ImportError: DLL load failed while importing _C in QGIS.


