• QuaternionsRock@lemmy.world
    link
    fedilink
    arrow-up
    15
    ·
    1 year ago

    You need to install Python package dependencies. pip install -r requirements.txt is the simplest way to do it, but that unfortunately installs the packages globally. May be wise to use a virtual environment.

    • humanplayer2@lemmy.ml
      link
      fedilink
      arrow-up
      8
      ·
      1 year ago

      Would pip install --user -r requirements.txt not be OK, too? I understand it’s not as isolated as a virtual environment, but it’s easy.

    • 30p87@feddit.de
      link
      fedilink
      arrow-up
      2
      ·
      1 year ago

      It needs to be installed globally or as root, as the script runs under root. Pip does not like being run with different permissions or as different users not at all tho.

  • Synthead@lemmy.world
    link
    fedilink
    arrow-up
    14
    ·
    edit-2
    1 year ago

    You should copy the console text and post it as a code block on your post. Not only is this easier to read, it’s searchable for others, and more accessible-friendly, too.

  • storm_koala@beehaw.org
    link
    fedilink
    arrow-up
    14
    arrow-down
    1
    ·
    edit-2
    1 year ago

    This script has two python modules as requirements, libevdev and inquirer. If you want to run the script with your systemwide python environment, you can try to find the relevant APT packages (often named python-MODULENAME) to install the modules on your system.

    Alternatively you can create a python virtual environment (you can easily find howtos) and install the requirements in the virtual environment using the pip tool. This way, the requirements will be installed for this project only.

    Also keep in mind to never use pip as sudo, it should not manage your systemwide python modules because it will conflict with your package manager.

    • storm_koala@beehaw.org
      link
      fedilink
      arrow-up
      1
      ·
      edit-2
      1 year ago

      Oh and good luck regarding your transition from windows to Ubuntu. I see that you had different issues for your first time, it can be though sometimes but keep going you will eventually get yourself confortable and understand new things on how it works. You will not regret it

  • Kleysley@discuss.tchncs.de
    link
    fedilink
    arrow-up
    3
    ·
    1 year ago

    On the Github page you linked it says under Installation: “Clone the repository and install the required dependencies enlisted in requirements.txt.

    It seems like you didnt do that…

  • NateSwift@beehaw.org
    link
    fedilink
    English
    arrow-up
    3
    ·
    edit-2
    1 year ago

    Disclaimer: I’m on mobile, please excuse and terrible formatting

    The issue that you’re running into is that the Python module “libevdev” isn’t installed.

    The traditional “best practice” for installing python modules is to create a python virtual environment (venv) for each project so they can have different versions of the same module. However, this will make running the script/program a little less convenient. I’ll include instructions for both, you only need to follow one.

    With a Virtual Environment

    The first thing we’ll want to do is create a virtual environment. This will let us install modules that don’t mess with the rest of the system.

    All of these commands should be run in the root folder of the application (the folder that src is inside of). Run the following command to create a folder (.venv) the virtual environment will be stored in.

    python -m venv .venv

    Next, we’ll want to activate the virtual environment. This needs to be done every time you run the application. If you’re using the bash shell the following command will active the virtual environment. (The bash shell is the default in Ubuntu. If you haven’t changed it this what you want)

    source .venv/bin/activate

    Now that we’ve created and activated a virtual environment, we can install the missing package.

    The repository you linked has a requirements.txt file we can use to install all the required modules without typing them out by hand. This can be done using pip and the ”-r” flag.

    pip install -r requirements.txt

    Now that everything is installed, you should be able to run the application as normal with:

    sudo python -m src

    If you close your terminal window, you’ll have to reactivate the virtual environment the next time you want to run the script/program. You can also write a bash script to do this for you.

    Without a Virtual Environment

    If you don’t want to setup a virtual environment, you can install the modules user wide. This will make it so the installed packages are available every time you run python. You can do this with pip as follows. Make sure to run this command in the root folder of the application (the folder src is in)

    pip install -r requirements.txt

    You should then be able to run the script/program as you did before with

    sudo python -m src