KeyError: AIRTABLE_API_KEY - python

Having some issues getting a web app up and running. You can see this project running live online at yx8dxjwh.apps.lair.io but as soon as I imported it into pyCharm I am presented with a key error for the api. Please see below:
python manage.py runserver
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x04678078>
Traceback (most recent call last):
File "C:\Program Files (x86)\Python36-32\lib\site-packages\airtable\auth.py", line 37, in __init__
self.api_key = api_key or os.environ['AIRTABLE_API_KEY']
File "C:\Program Files (x86)\Python36-32\lib\os.py", line 669, in __getitem__
raise KeyError(key) from None
KeyError: 'AIRTABLE_API_KEY'
There is a mass of other errors too but I feel like this is the main one and could potentially solve the rest of them.
Any help would be appreciated.

You don't have the environment variable set for AIRTABLE_API_KEY. The SDK you are using leverages that environment variable by default. You can read more at: https://airtable-python-wrapper.readthedocs.io/en/master/authentication.html
And then this link can help you find your Airtable API Key if you don't have it: https://support.airtable.com/hc/en-us/articles/219046777-How-do-I-get-my-API-key-

Related

runtime error while using Pvporcupine sdk for Picovoice python

I m using pvporcupine python SDK for picovoice for hot word detection, while using the below code I'm getting runtime error
import pvporcupine
access_key = "[my_acces_key]" # AccessKey obtained from Picovoice Console (https://picovoice.ai/console/)
#access key is altered for security reason
handle = pvporcupine.create(access_key=access_key, keywords=['porcupine'])
here is the error stack trace
Traceback (most recent call last):
File "c:/Users/Pjan/saa2/actions/pic_again.py", line 5, in <module>
handle = pvporcupine.create(access_key=access_key, keywords=['porcupine'])
File "C:\Users\Pjan\.conda\envs\sam_env\lib\site-packages\pvporcupine\__init__.py", line 82, in create
sensitivities=sensitivities)
File "C:\Users\Pjan\.conda\envs\sam_env\lib\site-packages\pvporcupine\porcupine.py", line 158, in __init__
raise self._PICOVOICE_STATUS_TO_EXCEPTION[status]()
pvporcupine.porcupine.PorcupineRuntimeError
here is the official site for picovoice SDK for python
any help is highly appreciated!
Well I contacted the official repository of picovoice and here I mentioned them what clearly was going on.
So anyone still facing it , then here is the solution for such behaviour https://github.com/Picovoice/porcupine/issues/617
Thanks!

Why does python shelf module give an error at start up when opening file

I have been using the python shelf module to store face encodings from the python face-recognition module below. I did this to make the live image recognition process faster.
I then imported these encodings in another script using the shelf module again, assigned them to a variable, and use them further down my script. This all works fine in the python idle environment and when I run it from the terminal. However, on startup, the shelf module fails to import the data. Can anyone tell me why this happens at start-up? The error I get on the log file is below. I have been stuck on it for a few days now. Is there a better way of storing and reusing the encodings? Thanks in advance.
the bit of code that fails on start-up but runs fine otherwise
import shelve
shelfFile = shelve.open('face_encodings')
known_encodings = shelfFile['known_encodings']
known_names = shelfFile['known_names']
shelfFile.close()
the error on startup
Traceback (most recent call last): File "/usr/lib/python3.7/shelve.py", line 111, in __getitem__
value = self.cache[key]
KeyError: 'known_encodings'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/pi/Desktop/run/testing.py", line 4, in <module>
known_encodings = shelfFile['known_encodings']
File "/usr/lib/python3.7/shelve.py", line 113, in __getitem__
f = BytesIO(self.dict[key.encode(self.keyencoding)])
KeyError: b'known_encodings'
face-recognition module
https://pypi.org/project/face-recognition/

Using language check module for python - "can't find Java" error

I'm planning to use the Language-check module for python 3 in my poem making code. I was just testing it with
import language_tool
lang_tool = language_tool.LanguageTool("en-US")
text = "A sentence with a error in the Hitchhiker’s Guide tot he Galaxy"
matches = lang_tool.check(text)
print(len(matches))
but it gave me this error.
Traceback (most recent call last):
File "/home/runner/.site-packages/language_tool/__init__.py", line 548, in get_server_cmd
cmd = cache["server_cmd"]
KeyError: 'server_cmd'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/runner/.site-packages/language_tool/__init__.py", line 559, in get_jar_info
java_path, jar_path = cache["jar_info"]
KeyError: 'jar_info'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "main.py", line 10, in <module>
lang_tool = language_tool.LanguageTool("en-US")
File "/home/runner/.site-packages/language_tool/__init__.py", line 188, in __init__
self._start_server_on_free_port()
File "/home/runner/.site-packages/language_tool/__init__.py", line 323, in _start_server_on_free_port
cls._start_server()
File "/home/runner/.site-packages/language_tool/__init__.py", line 335, in _start_server
server_cmd = get_server_cmd(cls._port)
File "/home/runner/.site-packages/language_tool/__init__.py", line 550, in get_server_cmd
java_path, jar_path = get_jar_info()
File "/home/runner/.site-packages/language_tool/__init__.py", line 563, in get_jar_info
raise JavaError("can’t find Java")
language_tool.JavaError: can’t find Java
I've looked at some similar questions and I know I probably need to put something in 'Path' but I don't know what specifically to enter. Thanks for your help!
Also I'm on doing this on repl.it, not IDLE.
Note: I'm adding this as an actual answer because the question was resolved in the comments.
Your question says:
Also I'm on doing this on repl.it, not IDLE.
That means that you need to install this module and all its prerequisites into your repl.it environment, not into your local machine.
On the BitBucket link you provided, under "Prerequisites", the page says:
LanguageTool requires Java 6 or later.
So you will need to ensure Java is installed into your repl.it environment somehow. I don't know whether that is possible or not. Alternatively, you can simply install this package and all its prerequisites locally instead.

Error while using Debug Console: DeprecationWarning: The `use_readline` parameter is deprecated and ignored since IPython 6.0

I have an issue with the Pycharm Debug console. Here's what I do step by step: I set a breakpoint somewhere in my code and when it stops at this breakpoint, I open the debug console as described here. This is prompted:
>>>
Then I try to do something basic like a = 1, but I get
this error message (screenshot). As copy-paste:
Traceback (most recent call last):
File "C:\dev\PyCharm Community Edition 2018.1\helpers\pydev\pydevconsole.py", line 362, in get_interpreter
interpreterInterface = getattr(__builtin__, 'interpreter')
AttributeError: module 'builtins' has no attribute 'interpreter'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\dev\PyCharm Community Edition 2018.1\helpers\pydev\_pydevd_bundle\pydevd_comm.py", line 1443, in do_it
result = pydevconsole.console_exec(self.thread_id, self.frame_id, self.expression, dbg)
File "C:\dev\PyCharm Community Edition 2018.1\helpers\pydev\pydevconsole.py", line 467, in console_exec
need_more = exec_code(CodeFragment(expression), updated_globals, frame.f_locals, dbg)
File "C:\dev\PyCharm Community Edition 2018.1\helpers\pydev\pydevconsole.py", line 383, in exec_code
interpreterInterface = get_interpreter()
File "C:\dev\PyCharm Community Edition 2018.1\helpers\pydev\pydevconsole.py", line 364, in get_interpreter
When I start doing this for a whole new python file, everything works out well, but instead of the >>> what is prompted is
In[2]:
Where is the difference coming from and what can I do to use the debug console in the first case?
In my case this was caused by pytest settings - I had set that warnings should be treated as errors.
I changed my pytest.ini by adding:
filterwarnings =
ignore:.*deprecated and ignored since IPython.*:DeprecationWarning
seems to solve the issue for me
>>> refers to the Python console while
In[2]:
is the IPython console, a kind of console on steroids.
Sometimes, a strange import can crash one thing and not the other. Maybe you could check on this one.

UnboundLocalError triggered during the deployment of a salt minion

During a minion deployment, a UnboundLocalError is raised by the git library used as a dependency of salt
An exception occurred in this state: Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/salt/state.py", line 1594, in call
**cdata['kwargs'])
File "/usr/lib/python2.7/dist-packages/salt/loader.py", line 1491, in wrapper
return f(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/salt/states/git.py", line 519, in latest
if remote_rev_type == 'sha1':
UnboundLocalError: local variable 'remote_rev_type' referenced before assignment
It is very unclear to know what happen here. Any clue?
This was a bug in the salt-stack library. Variable remote_rev_type was not initialized in all execution paths.
From the looks of the current salt-stack source code, I'd say it has been fixed.

Categories