Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issues with missing magick dependency #1

Closed
Botspot opened this issue Jan 2, 2024 · 9 comments
Closed

issues with missing magick dependency #1

Botspot opened this issue Jan 2, 2024 · 9 comments

Comments

@Botspot
Copy link

Botspot commented Jan 2, 2024

I am not sure if you are aware, but Debian Bookworm and onwards do not allow python packages to install globally. Your installation commands do not work on Bookworm.

pi@raspberrypi:~/FF-converter $ sudo pip3 install .
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.
    
    For more information visit http://rptl.io/venv

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.

The easiest option is to use a tool called pipx. See https://github.com/pypa/pipx

I have followed the instructions for installing globally for multi-user usage, resulting in the following command:

pi@raspberrypi:~/FF-converter $ sudo PIPX_HOME=/opt/pipx PIPX_BIN_DIR=/usr/local/bin pipx install . --force
Installing to existing venv 'ffmulticonverter'
  installed package ffmulticonverter 1.8.0, installed using Python 3.11.2
  These apps are now globally available
    - ffmulticonverter
done! ✨ 🌟 ✨

This succeeds. But running ffmulticonverter in a new terminal does not.

$ ffmulticonverter
Traceback (most recent call last):
  File "/usr/local/bin/ffmulticonverter", line 4, in <module>
    from ffmulticonverter import ffmulticonverter
  File "/opt/pipx/venvs/ffmulticonverter/lib/python3.11/site-packages/ffmulticonverter/ffmulticonverter.py", line 24, in <module>
    from PyQt5.QtGui import QIcon, QKeySequence
ModuleNotFoundError: No module named 'PyQt5'

Most likely, you just need to add PyQt5 to some list of dependencies somewhere to get it to work. I am hoping you can try this and see what it takes to get it working.

I would try this myself but I am fairly inexperienced when it comes to troubleshooting python projects. Tagging @theofficialgman here in case he has anything to suggest or spots anything incorrect that I have stated.

@Botspot
Copy link
Author

Botspot commented Jan 2, 2024

OK, it looks like using pipx to install in a different way yields better results.

sudo PIPX_HOME=/opt/pipx PIPX_BIN_DIR=/usr/local/bin pipx uninstall ffmulticonverter
sudo PIPX_HOME=/usr/local/pipx PIPX_BIN_DIR=/usr/local/bin pipx install --system-site-packages git+https://github.com/l-koehler/FF-converter.git

But now there is a new issue due to there being no magick command available.

pi@raspberrypi:~ $ ffmulticonverter
Traceback (most recent call last):
  File "/usr/local/bin/ffmulticonverter", line 5, in <module>
    ffmulticonverter.main()
  File "/usr/local/pipx/venvs/ffmulticonverter/lib/python3.11/site-packages/ffmulticonverter/ffmulticonverter.py", line 493, in main
    converter = MainWindow()
                ^^^^^^^^^^^^
  File "/usr/local/pipx/venvs/ffmulticonverter/lib/python3.11/site-packages/ffmulticonverter/ffmulticonverter.py", line 219, in __init__
    self.all_supported_conversions = utils.get_all_conversions()
                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/pipx/venvs/ffmulticonverter/lib/python3.11/site-packages/ffmulticonverter/utils.py", line 108, in get_all_conversions
    completed_process = subprocess.run(['magick', 'identify', '-list', 'format'], capture_output=True, text=True)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/subprocess.py", line 548, in run
    with Popen(*popenargs, **kwargs) as process:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/subprocess.py", line 1024, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.11/subprocess.py", line 1901, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'magick'

This seems to be a common problem. See: https://askubuntu.com/questions/1315603/where-is-the-magick-command-of-imagemagick

On my fully updated Bookworm system, there is no magick command available to be installed.

$ apt-file search magick | grep 'magick$'
graphicsmagick: /usr/lib/mime/packages/graphicsmagick
graphicsmagick: /usr/share/menu/graphicsmagick
graphicsmagick-libmagick-dev-compat: /usr/include/magick
imagemagick: /usr/share/bug/imagemagick
imagemagick-6-doc: /usr/share/doc-base/imagemagick-6-doc.imagemagick
perlmagick: /usr/share/bug/perlmagick
perlmagick: /usr/share/doc/perlmagick
pfstools: /usr/bin/pfsinimgmagick
pfstools: /usr/bin/pfsoutimgmagick
r-cran-magick: /usr/lib/R/site-library/magick/R/magick
seqmagick: /usr/bin/seqmagick
zsh-common: /usr/share/zsh/functions/Completion/Unix/_graphicsmagick
zsh-common: /usr/share/zsh/functions/Completion/Unix/_imagemagick

Could you try to see where the magick command originated from on your system, and if it would be possible to make ff-converter use other commands like convert or graphicsmagick?

@theofficialgman
Copy link

magick should be created as an alternative during imagemagic install

Does which magick have any output (assuming you already have imagemagick installed from apt)?

@l-koehler
Copy link
Owner

I think it should now work if 'convert' is present instead of 'magick'.
It should also work a lot better with missing dependencies in general.
We could consider making the install script alias magick to convert, if only convert exists at the time of install.

@Botspot Botspot changed the title Not working under pipx (missing pyqt5) issues with missing magick dependency Jan 2, 2024
@Botspot
Copy link
Author

Botspot commented Jan 2, 2024

@l-koehler The same error occurs as before.

pi@raspberrypi:~ $ ffmulticonverter
Traceback (most recent call last):
  File "/usr/local/bin/ffmulticonverter", line 5, in <module>
    ffmulticonverter.main()
  File "/usr/local/pipx/venvs/ffmulticonverter/lib/python3.11/site-packages/ffmulticonverter/ffmulticonverter.py", line 495, in main
    converter = MainWindow()
                ^^^^^^^^^^^^
  File "/usr/local/pipx/venvs/ffmulticonverter/lib/python3.11/site-packages/ffmulticonverter/ffmulticonverter.py", line 220, in __init__
    self.all_supported_conversions = utils.get_all_conversions(missing=missing)
                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/pipx/venvs/ffmulticonverter/lib/python3.11/site-packages/ffmulticonverter/utils.py", line 128, in get_all_conversions
    completed_process = subprocess.run(['magick', 'identify', '-list', 'format'],
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/subprocess.py", line 548, in run
    with Popen(*popenargs, **kwargs) as process:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/subprocess.py", line 1024, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.11/subprocess.py", line 1901, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'magick'

My first guess was that pipx failed to upgrade ffmulticonverter correctly, but the installed python program seems to match your latest version.

pi@raspberrypi:~ $ sha1sum '/usr/local/pipx/venvs/ffmulticonverter/lib/python3.11/site-packages/ffmulticonverter/ffmulticonverter.py'
74ce27e1e7cb63a155a2d1e79ec1bab656a83866  /usr/local/pipx/venvs/ffmulticonverter/lib/python3.11/site-packages/ffmulticonverter/ffmulticonverter.py
pi@raspberrypi:~ $ wget -qO- 'https://raw.githubusercontent.com/l-koehler/FF-converter/master/ffmulticonverter/ffmulticonverter.py' | sha1sum
74ce27e1e7cb63a155a2d1e79ec1bab656a83866  -

@l-koehler, on your system, could you try temporarily renaming the magick command on your system to see if this error occurs for you as well?

@l-koehler
Copy link
Owner

I uninstalled imagemagick and it still works.
It even shows the missing dependency in the bottom corner.
Neither 'magick' nor 'convert' are valid commands for me now.

@Botspot
Copy link
Author

Botspot commented Jan 2, 2024

With all imagemagick* packages uninstalled, it works for me too, and correctly shows the missing dependency in the bottom corner.

Looks like this corner case is still a problem on my system with your latest version.

@l-koehler
Copy link
Owner

it should work now on the latest version.
the dependency check correctly found that you have 'convert' instead of 'magick' and marked the dependency as not missing, but i missed a line that didnt consider 'convert' and used 'magick'.

@Botspot
Copy link
Author

Botspot commented Jan 2, 2024

It launches now. I will open a new issue if I encounter any new problems.

@Botspot Botspot closed this as completed Jan 2, 2024
@theofficialgman
Copy link

magick should be created as an alternative during imagemagic install

Does which magick have any output (assuming you already have imagemagick installed from apt)?

Sorry forgot the details here. magick is the new command provided by imagemagick version 7. It seems that ubuntu/debian never packaged that version and continue to package imagemagick 6 to this day. More info on why here -> ImageMagick/ImageMagick#6612

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants