Prompt-Engineering-Guide
Prompt-Engineering-Guide copied to clipboard
TypeError: str expected, not NoneType
How to fix the error below:
/usr/lib/python3.8/os.py in encode(value) 748 def encode(value): 749 if not isinstance(value, str): --> 750 raise TypeError("str expected, not %s" % type(value).name) 751 return value.encode(encoding, 'surrogateescape') 752 def decode(value):
TypeError: str expected, not NoneType
when running "os.environ["SERPAPI_API_KEY"] = os.getenv("SERPAPI_API_KEY")"? Thanks.
As mentioned in the previous comments, you need to get an API key and set up an environment variable for the API keys.
You are getting this error because there is no SERPAPI_API_KEY detected. I use dotenv library to load environment variables. Check out this tutorial for how you might do this: https://dev.to/emma_donery/python-dotenv-keep-your-secrets-safe-4ocn