How do you use a non-built-in Python libraries in apps?

I’m building an application with Builder. I want to import Requests library. I get an error:

Application started at 15:08:33
Traceback (most recent call last):
  File "/app/bin/evade", line 45, in <module>
    from evade import main
  File "/app/share/evade/evade/main.py", line 31, in <module>
    from .window import EvadeWindow
  File "/app/share/evade/evade/window.py", line 35, in <module>
    import requests
ModuleNotFoundError: No module named 'requests'
Application exited

Requests is installed with pip on my system.

Are you using the flatpak version? Maybe it comes with its own python, so you might need to try installing libraries with pip from inside builder

Fedora packages requests. Normally you would use dnf to install requests.

sudo dnf install python3-requests

If you used pip to install into a venv that would be ok.
Other uses of pip can lead to problems.
How, exactly, did you use pip to install requests?

1 Like

In my experience, when using pip as a regular user (not using sudo) the packages are installed under the users home directory (in ~/.local/lib/python3.NN/site-packages/) and those packages are used only by that user. If using sudo pip the packages are installed as system packages and have a chance of overwriting other system installed modules and may mess up other things.

Users should always use pip with the intent of only using those packages for personal use to avoid problems with the system installed python.

1 Like

Ever using pip as a user can have an impact.
What is encouraged is to always use a venv if anything is installed with pip.

As a user if you run a command that uses python then your user installed packages can break it.

sudo dnf install python3-requests

Says the package is already installed.

Installing with pip with sudo outputs:

sudo pip install requests
Requirement already satisfied: requests in /usr/lib/python3.13/site-packages (2.32.3)
Requirement already satisfied: charset-normalizer<4,>=2 in /usr/lib/python3.13/site-packages (from requests) (3.3.2)
Requirement already satisfied: idna<4,>=2.5 in /usr/lib/python3.13/site-packages (from requests) (3.7)
Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/lib/python3.13/site-packages (from requests) (1.26.20)
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager, possibly rendering your system unusable.It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv. Use the --root-user-action option if you know what you are doing and want to suppress this warning.

I know how to use virtual environments, but IDK how to put my Builder project inside of it.

No, the Builder program comes from the official DNF repository.

If you intend to debug a python app sometime in the future, it would be wise to use a virtual python environment which will enable you to debug in the same environment that was used for development. As a user, you may create many virtual python environments.

Here is a link to appropriate documentation:

Install packages in a virtual environment using pip and venv

1 Like

Using these with Builder seems an unsolved problem Reddit - Dive into anything