flet-dev / flet

Flet enables developers to easily build realtime web, mobile and desktop apps in Python. No frontend experience required.
https://flet.dev
Apache License 2.0
9.96k stars 392 forks source link

libmpv.so.1 not found (when libmpv is already installed) - fixable but hacky #2823

Open yashasolutions opened 4 months ago

yashasolutions commented 4 months ago

The problem

error while loading shared libraries: libmpv.so.1

$ python counter.py
/home/user/.flet/bin/flet-0.21.1/flet/flet: error while loading shared libraries: libmpv.so.1: cannot open shared object file: No such file or directory
Traceback (most recent call last):
  File "/home/user/code/flet/counter.py", line 29, in <module>
    flet.app(target=main)
  File "/home/user/code/flet/.venv/lib/python3.11/site-packages/flet_runtime/app.py", line 70, in app
    return asyncio.run(
           ^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/home/user/code/flet/.venv/lib/python3.11/site-packages/flet_runtime/app.py", line 207, in app_async
    await conn.close()
  File "/home/user/code/flet/.venv/lib/python3.11/site-packages/flet_runtime/flet_socket_server.py", line 191, in close
    if self.__receive_loop_task:
       ^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'FletSocketServer' object has no attribute '_FletSocketServer__receive_loop_task'. Did you mean: '_FletSocketServer__receive_loop'?

However, mpv is installed on the system (linux Arch):

$ ls -l /usr/lib/libmpv.so*
libmpv.so        libmpv.so.2      libmpv.so.2.2.0

The hacky fix

so a quick symlink can fix the problem:

 sudo ln -s /usr/lib/libmpv.so /usr/lib/libmpv.so.1

and then it works but I am sure the dependency resolution could figure this out on its own without this kind solution.

(side note: just found about Flet today, it looks amazing, can't wait to give a go with a real project)

Lucifer516-hp commented 4 months ago

well, for me I had to link the libraries again and again and still no improved, had to link libmpv, libmujs, lua5.2 and then jepg turbo still no improvement

syleishere commented 4 months ago

apt install libmpv1 this works for me at least under ubuntu 22.04

I do however get following: (flet:29655): CRITICAL : 03:35:11.411: void update_pressing_state(FlKeyEmbedderResponder *, uint64_t, uint64_t): assertion 'lookup_hash_table(self->pressing_records, physical_key) != 0' failed /usr/local/lib/python3.12/dist-packages/flet_core/page.py:292: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC). self.__expires_at = datetime.utcnow() + timedelta(

The counter app however does work as intended

syleishere commented 4 months ago

There is a bigger problem though Screenshot 2024-03-09 042006

Picture on left is running as root, picture on right is running as normal user....

syleishere commented 4 months ago

Hmm this only happening with WSL Ubuntu-22.04, I don't see it happening as normal VM Ubuntu-22.04.

Lucifer516-sudoer commented 3 months ago

Can you try it on a arch vm ?

syleishere commented 3 months ago

You mean under WSL? Only reason I install Ubuntu 22.04LTS is 90% of developers develop there and all code examples use latest Ubuntu LTS distro, any reason you use arch? I could try it, I think I'd have to be persuaded though, my main go to OS is FreeBSD for anything that needs to run rock solid for a decade, with godly ports collection bigger than any other OS :) For flutter/flet I run flutter/flet under apache in FreeBSD as well.

My main development environment though is Windows 11, Ubuntu WSL. From there I can test windows, Linux, android and android TV with adb, as well as web with FreeBSD and apache.

I mean if you were gonna release an APP, you would want to install it mainly on google play store, apple store. Package it for windows/mac and offer it as a service under apache/nginx right? I may see a point if you are trying to run a GUI for a raspberry pi, other than that I can't see why anyone would run arch over FreeBSD.

Here are some instructions for running latest Ubuntu WSL under windows 11: https://blog.sunsaturn.com/wsl/using-wsl-as-regular-linux-host-on-same-network-with-10-gigabit-and-nfs/

lokcito commented 2 months ago

In Debian 12 - Debian GNU/Linux 12 (bookworm) Being root: apt install libmpv-dev mpv dpkg -L libmpv-dev the output is:

/usr /usr/include /usr/include/mpv /usr/include/mpv/client.h /usr/include/mpv/render.h /usr/include/mpv/render_gl.h /usr/include/mpv/stream_cb.h /usr/lib /usr/lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu/pkgconfig /usr/lib/x86_64-linux-gnu/pkgconfig/mpv.pc /usr/share /usr/share/doc /usr/share/doc/libmpv-dev /usr/share/doc/libmpv-dev/changelog.Debian.gz /usr/share/doc/libmpv-dev/changelog.gz /usr/share/doc/libmpv-dev/copyright /usr/lib/x86_64-linux-gnu/libmpv.so

Then I've applied the symbol: ln -s /usr/lib/x86_64-linux-gnu/libmpv.so /usr/lib/libmpv.so.1

and it worked for me.

loleg commented 2 months ago

In the documentation it currently says "libmpv libraries must be installed if your Flet app uses Video control." This deserves more investigation, or the docs should be corrected if libmpv is a requirement for all projects.

yashasolutions commented 2 months ago

to add to @loleg, it would also be good to know which version is required, because I had libmpv, just libmpv.so.2 didn't cut it and it required libmpv.so.1

mayconrcampos commented 1 month ago

Just to report this same error on OpenSUSE Tumbleweed.

$ error while loading shared libraries: libmpv.so.1: cannot open shared object file: No such file or directory

ivanhercaz commented 1 month ago

I confirm this workaround works fine with Manjaro too! Thank you, @yashasolutions.

pedrobezerra14 commented 1 month ago

Tive esse mesmo problema ao tentar rodar um programa em Python em uma distribuição Linux brasileira, Biglinux(que é baseada em Arch). A solução: sudo ln -s /usr/lib/libmpv.so /usr/lib/libmpv.so.1 Funcionou perfeitamente, muito obrigado @yashasolutions !!!!

English:

I had this same problem when trying to run a Python program on a Brazilian Linux distribution, Biglinux (which is based on Arch). The solution: sudo ln -s /usr/lib/libmpv.so /usr/lib/libmpv.so.1 It worked perfectly, thank you very much @yashasolutions!!!!

Lucifer516-sudoer commented 1 month ago

Tive esse mesmo problema ao tentar rodar um programa em Python em uma distribuição Linux brasileira, Biglinux(que é baseada em Arch). A solução: sudo ln -s /usr/lib/libmpv.so /usr/lib/libmpv.so.1 Funcionou perfeitamente, muito obrigado @yashasolutions !!!!

English:

I had this same problem when trying to run a Python program on a Brazilian Linux distribution, Biglinux (which is based on Arch). The solution: sudo ln -s /usr/lib/libmpv.so /usr/lib/libmpv.so.1 It worked perfectly, thank you very much @yashasolutions!!!!

nice, but for me it is still not working, i am being asked to link multiple dependencies, I think flet team must jump into this pit and help us

FeodorFitsner commented 1 month ago

Hold on guys, I'm working on "light" version of desktop client for Linux with Audio/Video disabled: https://github.com/flet-dev/flet/issues/3163

HenryAreiza commented 2 weeks ago

In Ubuntu 24.04 LTS, I got the same error and solved it with this:

sudo apt update sudo apt install libmpv-dev libmpv2 sudo ln -s /usr/lib/x86_64-linux-gnu/libmpv.so /usr/lib/libmpv.so.1

Credits for this YouTube tutorial: https://youtu.be/dA53LgkDFEw?si=Z7n8YpGLOfJ2q_tw