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

FileNotFoundError: [Errno 2] No such file or directory: 'pngquant' #300

Open
whenmoon opened this issue Nov 14, 2023 · 0 comments
Open

FileNotFoundError: [Errno 2] No such file or directory: 'pngquant' #300

whenmoon opened this issue Nov 14, 2023 · 0 comments
Labels

Comments

@whenmoon
Copy link

whenmoon commented Nov 14, 2023

Describe the bug
My python script runs correctly when I run it using Python3 app.py but when using python-shell to run the script it fails with the error:

Traceback (most recent call last):
  File "/Users/user/Desktop/code/lang-sa/lang-segment-anything/app.py", line 68, in <module>
    heic_img.save('/Users/user/Downloads/IMG_4313.png')
  File "/Users/user/miniconda3/lib/python3.11/site-packages/heic2png/heic2png.py", line 53, in save
    subprocess.run(['pngquant', '--quality', quality_str, '-f', '-o', str(output_path), str(output_path)])
  File "/Users/user/miniconda3/lib/python3.11/subprocess.py", line 548, in run
    with Popen(*popenargs, **kwargs) as process:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/user/miniconda3/lib/python3.11/subprocess.py", line 1026, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/Users/user/miniconda3/lib/python3.11/subprocess.py", line 1950, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'pngquant'

Python code
Relevant Python code to reproduce the problem

import numpy as np
from lang_sam.utils import draw_image
from PIL import Image
from lang_sam import LangSAM
from heic2png import HEIC2PNG
import torch
from PIL import Image
from torchvision.utils import draw_bounding_boxes
from torchvision.utils import draw_segmentation_masks
import os
os.environ['CURL_CA_BUNDLE'] = ''

def draw_image(image, masks, boxes, labels, alpha=1):
    image = torch.from_numpy(image).permute(2, 0, 1)
    if len(boxes) > 0:
        image = draw_bounding_boxes(image, boxes, colors=['red'] * len(boxes), labels=labels, width=2)
    if len(masks) > 0:
        image = draw_segmentation_masks(image, masks=masks, colors=['white'] * len(masks), alpha=alpha)
    return image.numpy().transpose(1, 2, 0)

heic_img = HEIC2PNG('/Users/user/Downloads/IMG_4313.heic', quality=70)  # Specify the quality of the converted image
heic_img.save('/Users/user/Downloads/IMG_4313.png') <<<< error on this line
... 

Javascript code

const options = {
  pythonPath: '/Users/user/miniconda3/bin/Python3',
};

PythonShell.run('/Users/user/Desktop/code/lang-sa/lang-segment-anything/app.py', options).then(messages => {

Expected behavior
A description of what you expected to happen.
The script runs as normal without failure

Actual behavior
A description of what actually happened.
The script fails / errors. It's like it can't find the required libraries because we are running the script from a node server and not the directory of the script.

Other Information (please complete the following information):

  • OS: MacOs 12.6
  • Python Version 3.11.5
  • Node Version 18.2

Additional context
Add any other context about the problem here.

@whenmoon whenmoon added the bug label Nov 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant