I feel like I'm asking a dumb question, but I've looked at multiple StackOverflow threads and articles online already but still haven't fixed my problem.
I'm trying to use the OpenAI Python library to train a new model, but even after running multiple variations of the pip install openai
command, VS Code and Powershell keep returning this:
Import "openai" could not be resolvedPylancereportMissingImports
and
PS C:\Users\achar\OneDrive\Documents\GitHub\TaxGPT> openai --version
openai: The term 'openai' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Here are some of the commands I've already tried:
pip install openai
pip install openai --user
pip install --upgrade pip
pip install --upgrade pip
pip3 install --upgrade openai --user
pip3 install --upgrade --force-reinstall openai --user
Thanks for your help, I really do appreciate it!
Have you set the Python PATH?
In command terminal, run:
where python
to return the location where python is installed.
In VSCode, open settings.json, which can be quickly accessed using command palette (CTRL + SHIFT + P
) and typing settings.json
. Choose the Preferences: Open User Settings (JSON)
.
Copy the path returned in the terminal.
In the file, add the line:
"python.defaultInterpreterPath": <THE PATH YOU COPIED>,
If the path you copied contains backslash, replace them with double backslash or single forward slash.
For example,
"python.defaultInterpreterPath": "C:\\Users\\<YOURUSERNAME>\\AppData\\Local\\Programs\\Python\\Python311\\python.exe",
I highly recommend reading the documentation in VSCode for Python: https://code.visualstudio.com/docs/python/settings-reference
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With