• Installing a python package with pipx

    From Richmond@21:1/5 to All on Sat Jun 1 18:20:01 2024
    I have been trying to install this:

    https://pypi.org/project/musicpy/#description

    with not much success.

    I have done these:

    sudo aptitude install pip
    sudo aptitude install pipx
    pipx ensurepath
    pipx install --include-deps musicpy

    (logged out and in to get updated PATH)

    pipx run musicpy
    'musicpy' executable script not found in package 'musicpy'.
    Available executable scripts:

    I think it is installed, but how do I run it?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Richmond@21:1/5 to Richard on Sat Jun 1 18:50:01 2024
    Richard <rrosner5@gmail.com> writes:

    If you haven't closed the terminal window/logged out, you need to run
    source .bashrc. Running pipx ensurepath should have said something
    like that.

    Yes, I did this:

    (logged out and in to get updated PATH)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Richmond@21:1/5 to Richard on Sat Jun 1 19:20:01 2024
    Richard <rrosner5@gmail.com> writes:

    Looking at the package, no wonder it fails. musicpy doesn't contain
    anything that can be executed. So pipx run can't work for obvious
    reasons. You'll have to install it with pipx install and use it in a
    python script.

    https://pypi.org/project/musicpy/


    OK so I have found:

    ./.local/pipx/venvs/musicpy/lib/python3.11/site-packages/musicpy/musicpy.py

    But:

    python3.11
    Python 3.11.2 (main, Mar 13 2023, 12:18:29) [GCC 12.2.0] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    import musicpy
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    ModuleNotFoundError: No module named 'musicpy'

    I guess I have to tell python where to look?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Richmond@21:1/5 to Richard on Sat Jun 1 22:10:01 2024
    Richard <rrosner5@gmail.com> writes:

    That's the point of venv's. pipx runpip should do the trick. Or the
    classic way: source path/to/venv/bin/activate. That way you activate
    the position virtual environment (venv) created in that directory
    with all packages installed in that venv.


    I got it working by doing:

    python3 -m venv .local/pipx/venvs/musicpy/

    .local/pipx/venvs/musicpy/bin/python3.11

    Then I was able to import musicpy from the python shell.

    How bewildering!

    Thanks.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Richmond@21:1/5 to Richard on Sat Jun 1 23:10:01 2024
    Richard <rrosner5@gmail.com> writes:

    Pretty much just what pipx does.


    Well I don't know how.

    Now I need to run idle in my new environment. I have installed it

    .local/pipx/shared/bin/pip install idle

    and it is here:

    .local/pipx/shared/lib/python3.11/site-packages/idle.py

    but I don't know how to run it. I just get errors.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Richmond@21:1/5 to Richard on Sun Jun 2 00:00:01 2024
    Richard <rrosner5@gmail.com> writes:

    A packages documentation is always your best friend: https://pypi.org /project/idle/


    Yes it makes it look easy there, but:

    import idle
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File ".local/pipx/shared/lib/python3.11/site-packages/idle.py", line 4, in <module>
    from layout import *
    ModuleNotFoundError: No module named 'layout'



    Also, python script isn't a necessarily a standalone executable. And
    also, you shouldn't just wildly mix pipx commands with pip commands
    if you don't know what you are doing. Either create a venv with
    python3 -m venv or use pipx, not both. Once created, stick to these
    separate paths. And read the documentation of pipx while you're at
    it. Sure, venvs are easy to handle, as you can just delete them and
    start from scratch, but mixing commands without knowing what one is
    doing is just a recipe for desaster.


    I don't know what I am doing for sure. But I did not wildly mix, I just
    kept trying things until I found something which worked. Most things
    didn't, and still don't.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Richmond@21:1/5 to All on Sun Jun 2 14:00:01 2024
    OK Back on Debian, I removed the one package installed with pipx, which
    was musicpy, then tried to install it with pip, but got this message
    which actually tells me to use pipx. (There is no package python-musicpy).

    pip install musicpy
    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Richmond@21:1/5 to Richard on Sun Jun 2 13:50:02 2024
    Richard wrote:


    On Sat, Jun 1, 2024, 23:50 Richmond <dnomhcir@gmx.com <mailto:dnomhcir@gmx.com>> wrote:

    Richard <rrosner5@gmail.com <mailto:rrosner5@gmail.com>> writes:

    > A packages documentation is always your best
    friend: https://pypi.org
    > /project/idle/
    >

    Yes it makes it look easy there, but:

    import idle
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File ".local/pipx/shared/lib/python3.11/site-packages/idle.py",
    line 4, in <module>
        from layout import *
    ModuleNotFoundError: No module named 'layout'

    That's what I'm talking about. You wildly mix commands together that
    don't go together. And whatever is off with your paths. Things of pipx installed packages should be in .local/bin and .local/shared/pipx. At
    least on Debian that's the default. No idea what you did.


    I don't think your assessment is correct, as I have booted opensuse,
    where I do not even have pipx installed and have not used it. I did
    these commands:

    1059  pip install musicpy
     1062  pip install idle

    I got the layout error so:

     1065  pip install layout

    cured the layout error but then I got a gui error

     1067  pip install gui

    There is no such package.

    .local/lib/python3.6/site-packages/idle.py", line 26, in <module>
        gui.mainloop()
    NameError: name 'gui' is not defined

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Richmond@21:1/5 to Richard on Sun Jun 2 14:30:01 2024
    Richard <rrosner5@gmail.com> writes:


    That's how its done. Also, complaining here about something that
    doesn't even work on other distros and thus can't be a Debian problem doesn't make that much sense.

    I am not complaining, I am trying to find out how to get it working. And
    as pip (and pipx) are debian packages I think it is reasonable to
    discuss it on the debian user list.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Richmond@21:1/5 to Richard on Sun Jun 2 14:50:01 2024
    Richard <rrosner5@gmail.com> writes:

    python3 -m venv venv
    source venv/bin/activate
    pip install musicpy

    OK thanks. And apparently to get idle working I do:

    python -m idlelib.idle

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)