CLI data preparation tool Windows

I know why it’s not working for Windows users running ‘openai’ CLI commands through Command Prompt and PowerShell, as well as why this will work for Windows users running it using ‘Git Bash’:

When you call ‘openai’ in Command Prompt and Powershell, the system will traverse the PATH system variable which contains a list of directories to look through to find ‘openai’ (Like when you call ‘Notepad’ which is the same as running ‘C:\Windows\System32\Notepad.exe’). The ‘openai’ file can be found inside of ‘[Python install directory]\Scripts’. So for me, the directory is ‘C:\Users\iadmin\AppData\Local\Programs\Python\Python39\Scripts\openai’, however it does not have an extension as you can see:

Because of this, Command Prompt and PowerShell will ask you which program you want to open the file in, but selecting ‘Python.exe’ will simply run the program and not keep it open interactively. I’m trying to find a current workaround for this.


Git Bash works though, and after a little investigating as to why, I figured it out. The ‘openai’ file will contain something like this at the top (Shows up different for everyone):

#!C:\Users\iadmin\AppData\Local\Programs\Python\Python39\python.exe

That line starts with ‘#!’ and essentially tells Git Bash what interpreter to use (in this case, Python). So it will launch the Python shell and then run ‘openai’ which is essentially a Python file. Git Bash is a Bash emulator so it analyzes the ‘openai’ file differently than Command Prompt and PowerShell.

For now, I highly recommend downloading Git Bash for now to support running the OpenAI CLI commands on Windows!

4 Likes