Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Open
Labels
@whenmoon

Description

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /