Skip to content

Conversation

@rasapala
Copy link

Add import sys.exit to optimum_cli.py.
optimum_cli.exe when run with no parameters throws error missing name: exit.

@IlyasMoutawwakil
Copy link
Member

@rasapala where do you get this error ? windows ?

@rasapala
Copy link
Author

Yes it was discovered on windows.

@IlyasMoutawwakil
Copy link
Member

@rasapala and why would anyone run optimum cli with no params ? 😅
whats being fixed here exactly, please elaborate

@rasapala
Copy link
Author

I have run into the problem while checking optimum-cli installation. First command to run to check if its available in env PATH is to run optimum-cli command. Then the problem occurred. I have worked around it and checked optimum-cli -h and everyone can do that but I wanted to let you know that this scenario may happen and this is a fix for it.

@IlyasMoutawwakil
Copy link
Member

I just pip installed optimum in my windows env and ran optimum-cli.exe and it worked fine

Successfully installed MarkupSafe-3.0.2 filelock-3.19.1 fsspec-2025.9.0 huggingface_hub-0.34.4 jinja2-3.1.6 mpmath-1.3.0 networkx-3.5 optimum-1.27.0 pyyaml-6.0.2 regex-2025.9.1 safetensors-0.6.2 setuptools-80.9.0 sympy-1.14.0 tokenizers-0.22.0 torch-2.8.0 transformers-4.56.1
PS C:\Users\ilyas> optimum-cli.exe
usage: optimum-cli

positional arguments:
  {export,env}
    export      Export PyTorch and TensorFlow models to several format.
    env         Get information about the environment used.

options:
  -h, --help    show this help message and exit
PS C:\Users\ilyas> 

is this related to a specific python version ?

@rasapala
Copy link
Author

Yes, it fails on newer python version like 3.12.10.

@IlyasMoutawwakil
Copy link
Member

sorry I wasn't able to reproduce..
I did the following on my windows machine:

uv venv --python 3.12.10
.venv\Scripts\activate
uv pip install optimum
optimum-cli

and didn't get any errors 🤔

@rasapala
Copy link
Author

rasapala commented Oct 7, 2025

I think the problem occurs when you use standard Python installation procedures with python installer.
https://www.python.org/ftp/python/3.12.10/python-3.12.10-amd64.exe

@IlyasMoutawwakil
Copy link
Member

IlyasMoutawwakil commented Oct 7, 2025

hmm i wasn't able to reproduce, but was able to find references to this issue in the python org / cpython repo python/cpython#73089 what I suggest to do is to import sys and use sys.exit() in the cli tool instead of exit(), following the answer in https://stackoverflow.com/questions/19747371/python-exit-commands-why-so-many-and-when-should-each-be-used

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

Successfully merging this pull request may close these issues.

2 participants