[Python] How to call a Python script using several modules from a Bash script?

Discussão em 'Python' iniciado por Stack, Outubro 1, 2024.

  1. Stack

    Stack Membro Participativo

    Based on an answer, I've made a Bash script to install the requirements and run a Python script working with a MariaDB database. In WSL, the Python script runs well, but when I run the Bash script from Windows 11 command line, I get following error:

    ModuleNotFoundError: No module named 'mariadb'


    Unlike another question concerning the same error, I've verified by python3 -V I use Python 3.10 in the whole process. Commenting the MariaDB connector out has shown the same problem with other other imported modules. My Bash, editted:

    python3 -m venv "c:\path\to\venv"
    "c:\path\to\venv\Scripts\activate"
    pip3 install -r "c:/some/path/requirements.txt"
    python3 "c:/some/other/path/myscript.py"


    The requirements.txt file:

    mariadb==1.1.10
    datasets
    sentence_transformers


    EDIT: Thanks to the comments and answers, I've got rid of the following error:

    bash: venv/bin/activate: No such file or directory


    However, the main problem lasts, it just changed from ImportError to ModuleNotFoundError. All the requirements either install correctly, or report "Requirement already satisfied".

    Continue reading...

Compartilhe esta Página