wrwetzel / Birdland

Birdland Musician's Assistant - A music reader and librarian for fakebooks with audio and midi support.
MIT License
12 stars 1 forks source link

ImportError: No module named PySimpleGUI #3

Open strk opened 1 month ago

strk commented 1 month ago

It looks like the Install.sh script doesn't deal with installing dependencies as I get an error running birdland right after running ./Install.sh:

[strk@oli:/usr/local/src/music/Birdland(main)] birdland 
Traceback (most recent call last):
  File "/home/strk/.local/bin/birdland", line 25, in <module>
    import PySimpleGUI as sg
ModuleNotFoundError: No module named 'PySimpleGUI'

Unfortunately I cannot find a package if I search for PySimpleGUI in the apt cache ( apt cache search PySimpleGUI) so I'm stuck as to how to proceed. Ideas ? The recommended way of using pip is discouraged by Debian:

[strk@oli:/usr/local/src/music/Birdland(main)] pip install PySimpleGUI
error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
    python3-xyz, where xyz is the package you are trying to
    install.

    If you wish to install a non-Debian-packaged Python package,
    create a virtual environment using python3 -m venv path/to/venv.
    Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
    sure you have python3-full installed.

    If you wish to install a non-Debian packaged Python application,
    it may be easiest to use pipx install xyz, which will manage a
    virtual environment for you. Make sure you have pipx installed.

    See /usr/share/doc/python3.11/README.venv for more information.

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.
strk commented 1 month ago

I'm not a python expert but I've had some nice experience with pipx install <project>, how hard would it be to make it possible for birdland as well ?

strk commented 1 month ago

I've seen that PySimpleGUI is not opensource software, which explains why it isn't in Debian. Would you consider replacing its use with something that allows to really use your project as free software ?

wrwetzel commented 1 month ago

Sandro,

First, an apology for not getting back to you quickly. I've been busy but that's not a good excuse.

Second, I haven't touched Birdland in a while and I know I left it in a state that was inconvenient to install. I hope to get back to it in the next few months depending on available mindshare.

Now, to your notes. It appears that PySimpleGUI is still available free for non-commercial use but there is a little friction in the process of acquiring it. See: https://www.pysimplegui.com/faq

There is now a free version, FreeSimpleGUI, from another developer who copied the last free release of PySimple GUI, if I remember correctly. See: https://github.com/spyoungtech/FreeSimpleGUI

I had a quick go at trying it out but bumped up against an install problem with it and didn't put the time into resolving it.

I explored making Birdland installable with pip, plan to do so, but not immediately.

I'm afraid that Birdland is so dependent on PySimpleGUI that it would be hard to untangle it from that GUI. I specifically do not have a GUI abstraction layer that would make it easy to replace PySimpleGUI with another UI library. However, to your concern about "free software", I believe the FreeSimpleGUI will satisfy that need.

I think this about addresses your questions. Get back to me if not or you have more questions. Bill

wrwetzel commented 1 month ago

Sandro,

I just downloaded a copy of FreeSimpleGUI from:

 https://github.com/spyoungtech/FreeSimpleGUI/blob/v5.1.0/FreeSimpleGUI/FreeSimpleGUI.py

copied it to the Birdland src folder, commented out the PySimpleGUI include and added:

 import FreeSimpleGUI as sg

and Birdland launched and appeared to run OK. This give you a path to at least explore Birdland.

Bill

strk commented 1 month ago

I've tried doing as you suggested and after ./Install.sh and a few iterations of installing deps and tweaking PYTHONPATH I've got here:

        File "/home/strk/.local/share/birdland/birdland/fb_config.py", line 1160, in report_progress
            self.sg.popup( txt,
            ^^^^^^^^^^^^^
        AttributeError: module 'FreeSimpleGUI' has no attribute 'popup'

What about pushing your work in a branch so it's easier to test ? I have a lot of changes already in the worktree by following your instructions (used perl to batch-replace PySimpleGUI with FreeSimpleGUI everywhere:

     ReadMe-GitHub.md                                       |   2 +-
     ReadMe-Tar.md                                          |   2 +-
     requirements.txt                                       |   2 +-
     src/Documentation/_build/doctrees/birdland.doctree     | Bin 258209 -> 258247 bytes
     src/Documentation/_build/doctrees/environment.pickle   | Bin 44733 -> 44737 bytes
     src/Documentation/_build/html/_sources/birdland.md.txt |  12 ++++++------
     src/Documentation/_build/html/birdland.html            |  14 +++++++-------
     src/Documentation/birdland.md                          |  12 ++++++------
     src/Documentation/birdland.md.bak                      |   4 ++--
     src/birdland/DevNotes.txt                              |  22 +++++++++++-----------
     src/birdland/birdland.conf.proto                       |   4 ++--
     src/birdland/birdland.html                             |   2 +-
     src/birdland/birdland.py                               |   6 +++---
     src/birdland/fb_config.py                              |   6 +++---
     src/birdland/fb_layout.py                              |   6 +++---
     src/birdland/fb_pdf.py                                 |  10 +++++-----
     src/birdland/fb_utils.py                               |   8 ++++----
     17 files changed, 56 insertions(+), 56 deletions(-)
wrwetzel commented 1 month ago

Hmmm, I have no idea why popup() is not defined. I'll have to look into that and likely contact the FreeSimpleGUI developers.

"What about pushing your work in a branch so it's easier to test ?" - I'm afraid that I'm a complete beginner when it comes to git. I just learned enough to get this to github. I don't know what you mean by the question. Please explain or, better yet, tell me what to do.

I'll be glad to answer whatever questions you have but I won't have time for actual development work for a while. Several things in the queue ahead of Birdland.

Bill

strk commented 1 month ago

How to push your work in a branch:

  1. Create the branch (we'll call it "freeSimpleGui"): git branch freeSimpleGui
  2. Switch to the newly created branch: git checkout freeSimpleGui
  3. Modify the files as you see needed
  4. Commit the changes: git commit -a
  5. Push the branch to the github repository and indicate it as its upstream (I'm assuming the github remote is called "origin"): git push --set-upstream origin freeSimpleGui