openai / openai-python

The official Python library for the OpenAI API
https://pypi.org/project/openai/
Apache License 2.0
23.08k stars 3.25k forks source link

openai migration on Windows WSL error. instructions are wrong #1880

Open AMDphreak opened 1 day ago

AMDphreak commented 1 day ago

The migration guide section for Windows using WSL does not function properly. After running 'curl -fsSL https://docs.grit.io/install | bash' within the source code directory, the new bash instance does not have 'grit' included in the path variable. I am using an Ubuntu WSL image.

UPDATE Did some more diagnosing, turns out the pipe command does literally nothing for the user. Why are you piping the output of a curl statement without accessing the piped output in your bash command after the pipe? You made the terminal print the file into the void. The curl command literally produces the text from the file, not a file. You need to pipe this crap into a file, then run that file in the new bash instance.

curl -fsSL https://docs.grit.io/install > grit_install_script.sh | bash ./grit_install_script.sh

In addition, you need to include the install location in the user path variable, because this is what happens if you don't:

downloading grit 0.1.0-alpha.1731963650 x86_64-unknown-linux-gnu
installing to /home/ryan/.grit/bin
  grit
everything's installed!
ryan@IAmDevloper:/mnt/r/Google Drive/Code/Repositories/offline/openAI desktop user helper$ grit install
Command 'grit' not found, did you mean:

So add this command after the execution: export PATH=$PATH:$HOME/.grit/bin to append the install location after this, you do not need to do grit install it is redundant at this point. The problem with your script is you needed grit installed in order to run the grit install command, which makes a cyclic dependency.

Original post excerpt:

Automatic migration with grit on Windows

To use grit to migrate your code on Windows, you will need to use Windows Subsystem for Linux (WSL). Installing WSL is quick and easy, and you do not need to keep using Linux once the command is done.

Here's a step-by-step guide for setting up and using WSL for this purpose:

  1. Open a PowerShell or Command Prompt as an administrator and run wsl --install.
  2. Restart your computer.
  3. Open the WSL application.
  4. In the WSL terminal, cd into the appropriate directory (e.g., cd /mnt/c/Users/Myself/my/code/) and then run the following commands:
    curl -fsSL https://docs.grit.io/install | bash
    grit install
    grit apply openai

Then, you can close WSL and go back to using Windows.

Originally posted by @rattrayalex in https://github.com/openai/openai-python/discussions/742

AMDphreak commented 1 day ago

Looking inside the script file, it is apparent that the script should already set the path variable. I guess I just forgot to refresh the shell after running the downloaded script. Doesn't change the cyclic dependency though

    # * early-bound: export PATH="/home/myuser/.myapp:$PATH"
    # * late-bound:  export PATH="$HOME/.myapp:$PATH"
        export PATH="$_install_dir_expr:\$PATH"