[Python] Nixos - Flask - ModuleNotFoundError

Discussão em 'Python' iniciado por Stack, Abril 25, 2025.

  1. Stack

    Stack Membro Participativo

    I wanted to add a form to my flask-based website, but I got the following error message:

    Apr 24 21:18:04 nixos uwsgi[2261]: from flask_wtf import FlaskForm
    Apr 24 21:18:04 nixos uwsgi[2261]: ModuleNotFoundError: No module named 'flask_wtf'


    Here are the installed packages part of my the configuration.nix file:

    environment.systemPackages = with pkgs; [
    # vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default.
    git
    wget
    pkgs.notepadqq
    pkgs.nginx
    pkgs.postgresql_16
    pkgs.pgloader
    pkgs.libgcc
    pkgs.python312
    pkgs.python312Packages.virtualenv
    pkgs.uwsgi
    pkgs.mariadb_114
    pkgs.kdePackages.okular
    pkgs.libreoffice-qt-fresh
    pkgs.spotify
    pkgs.fwupd
    ];


    I intended to install any further python packages in virtualenv, but flask_wtf seems to be not recognised.

    Running the command "pip freeze" outside of my virtualenv gives the following response:

    [user@nixos:~]$ pip freeze
    The program 'pip' is not in your PATH. It is provided by several packages.
    You can make it available in an ephemeral shell by typing one of the following:
    nix-shell -p cope
    nix-shell -p python311Packages.pip
    nix-shell -p python312Packages.pip


    Running the command "pip freeze" in the virtualenv gives the following response:

    (folder_env)
    [user@nixos:/var/www/folder/folder_env/bin]$ pip freeze
    blinker==1.9.0
    click==8.1.8
    Flask==3.1.0
    Flask-WTF==1.2.2
    itsdangerous==2.2.0
    Jinja2==3.1.6
    MarkupSafe==3.0.2
    psycopg2-binary==2.9.10
    setuptools==78.1.0
    Werkzeug==3.1.3
    wheel==0.45.1
    WTForms==3.2.1



    As you see, Flask-WTF is installed here. Why is flask_wtf not found if it is installed? How should I resolve this?

    Thank you for your advice.

    Continue reading...

Compartilhe esta Página