Prompt-Engineering-Guide icon indicating copy to clipboard operation
Prompt-Engineering-Guide copied to clipboard

TypeError: str expected, not NoneType

Open gitfans5 opened this issue 2 years ago • 1 comments

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.

gitfans5 avatar Feb 24 '23 00:02 gitfans5

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

omarsar avatar Feb 24 '23 02:02 omarsar