Can't get openai python package working... please help!

OpenAI “help” is not in the business of diagnosing OS installs or giving programming lessons.

You might find some Mac experts that can help you figure out how to get pip to install things into the current operating environment, or create your own modifiable python install all in user environment, with path set to point to it.

If you want to ask an AI, here’s a chatbot that requires no additional libraries (this example refactored from using requests library by AI)

import os, json, urllib.request, urllib.error

model = "gpt-3.5-turbo-0125"
system = [{"role": "system", "content": f"You are ChatBro, an expert AI assistant powered by {model}"}]
user = [{"role": "user", "name": "intro", "content": "Provide brief introduction."}]
chat = []
params_template = {"model": model, "max_tokens": 666, "top_p":0.9,}
headers = {"Content-Type": "application/json",
           "Authorization": f"Bearer {os.environ.get('OPENAI_API_KEY')}"}

while not user[0]['content'] == "exit":
    request = {**params_template, **{"messages": system + chat[-10:] + user}}
        req = urllib.request.Request("", \
          headers=headers, data=json.dumps(request).encode())
        response = urllib.request.urlopen(req)
    except urllib.error.HTTPError as e:
        print(f"HTTP error {e.code}: {}")
        user = [{"role": "user", "content": input("\nPrompt: ")}]
    except Exception as e:
        print(f"Error: {e}")
        response_body = json.loads(
        reply = response_body['choices'][0]['message']['content']
    chat += user + [{"role": "assistant", "content": reply}]
    user = [{"role": "user", "content": input("\nPrompt: ")}]

The API key environment variable is needed as described before – or you can just paste it right into the code instead of {os.environ.get('OPENAI_API_KEY')}