Python pandas script throwing error in python 3.8 - python

Below code is working fine in python version 3.6.6 but when python upgraded to 3.8.1 I am getting error
num = Data["Description"].size
Below error I am getting in Python 3.8.1 version
"Elogmsg" : "Traceback (most recent call last):\n File \"/usr/local/lib/python3.8/site-packages/pandas/core/indexes/base.py\",
line 2897, in get_loc\n return self._engine.get_loc(key)\n File \"pandas/_libs/index.pyx\",
line 107, in pandas._libs.index.IndexEngine.get_loc\n File \"pandas/_libs/index.pyx\",
line 131, in pandas._libs.index.IndexEngine.get_loc\n File \"pandas/_libs/hashtable_class_helper.pxi\",
line 1607, in pandas._libs.hashtable.PyObjectHashTable.get_item\n File \"pandas/_libs/hashtable_class_helper.pxi\",
line 1614, in pandas._libs.hashtable.PyObjectHashTable.get_item\nKeyError: 'Description'\n\nDuring handling of the above exception,
another exception occurred:\n\nTraceback (most recent call last):\n File \"/var/www/Python/Project/march.py\",
line 161, in main\n num = Data["Description"].size\n File \"/usr/local/lib/python3.8/site-packages/pandas/core/frame.py\",
line 2995, in __getitem__\n indexer = self.columns.get_loc(key)\n File \"/usr/local/lib/python3.8/site-packages/pandas/core/indexes/base.py\",
line 2899, in get_loc\n return self._engine.get_loc(self._maybe_cast_indexer(key))\n File \"pandas/_libs/index.pyx\",
line 107, in pandas._libs.index.IndexEngine.get_loc\n File \"pandas/_libs/index.pyx\",
line 131, in pandas._libs.index.IndexEngine.get_loc\n File \"pandas/_libs/hashtable_class_helper.pxi\",
line 1607, in pandas._libs.hashtable.PyObjectHashTable.get_item\n File \"pandas/_libs/hashtable_class_helper.pxi\",
line 1614, in pandas._libs.hashtable.PyObjectHashTable.get_item\nKeyError: 'Description'\n",
Can anyone help me why code is not working in 3.8.1 python version

Related

How to fix this error in Pyttsx3: KeyError: 'VoiceAge'

I installed Pyttsx3 with mamba on Mac OS. All was working fine.
Then I upgraded to Mac OS Ventura 13.01 and I get an error on this minimal working example:
import pyttsx3
engine = pyttsx3.init()
engine.getProperty('voices')
The third line throws an error. Any ideas on why I get this error and how to fix it?:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/fdiacobe/opt/miniconda3/lib/python3.9/site-packages/pyttsx3/engine.py", line 146, in getProperty
return self.proxy.getProperty(name)
File "/Users/fdiacobe/opt/miniconda3/lib/python3.9/site-packages/pyttsx3/driver.py", line 173, in getProperty
return self._driver.getProperty(name)
File "/Users/fdiacobe/opt/miniconda3/lib/python3.9/site-packages/pyttsx3/drivers/nsss.py", line 69, in getProperty
return [self._toVoice(NSSpeechSynthesizer.attributesForVoice_(v))
File "/Users/fdiacobe/opt/miniconda3/lib/python3.9/site-packages/pyttsx3/drivers/nsss.py", line 69, in <listcomp>
return [self._toVoice(NSSpeechSynthesizer.attributesForVoice_(v))
File "/Users/fdiacobe/opt/miniconda3/lib/python3.9/site-packages/pyttsx3/drivers/nsss.py", line 64, in _toVoice
attr['VoiceAge'])
File "/Users/fdiacobe/opt/miniconda3/lib/python3.9/site-packages/objc/_convenience_mapping.py", line 18, in __getitem__objectForKey_
return container_unwrap(res, KeyError, key)
File "/Users/fdiacobe/opt/miniconda3/lib/python3.9/site-packages/objc/_convenience.py", line 122, in container_unwrap
raise exc_type(*exc_args)
KeyError: 'VoiceAge'

KeyError when deploying through Github to Heroku

I have pushed my repository through github. Myrepository can be found here: https://github.com/cody8522/fmv_app
I am receiving an error when deploying my app:
2022-05-27 14:10:40.585 Uncaught app exception
Traceback (most recent call last):
File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/caching/cache_utils.py", line 126, in get_or_create_cached_value
return_value = cache.read_value(value_key)
File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/caching/memo_decorator.py", line 408, in read_value
raise e
File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/caching/memo_decorator.py", line 401, in read_value
pickled_value = self._read_from_mem_cache(key)
File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/caching/memo_decorator.py", line 444, in _read_from_mem_cache
raise CacheKeyNotFoundError("Key not found in mem cache")
streamlit.caching.cache_errors.CacheKeyNotFoundError: Key not found in mem cache
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/scriptrunner/script_runner.py", line 443, in _run_script
exec(code, module.__dict__)
File "/app/fmv_app/web_app.py", line 39, in <module>
csv_load()
File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/caching/cache_utils.py", line 145, in wrapper
return get_or_create_cached_value()
File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/caching/cache_utils.py", line 135, in get_or_create_cached_value
return_value = func(*args, **kwargs)
File "/app/fmv_app/web_app.py", line 25, in csv_load
df = df.merge(pd.read_csv('Venue Information.csv').rename(columns={'Venue':'Name'})[['Name','Adjusted Capacity']],on='Name').drop('Unnamed: 0',axis=1)
File "/home/appuser/venv/lib/python3.9/site-packages/pandas/core/frame.py", line 7284, in merge
return merge(
File "/home/appuser/venv/lib/python3.9/site-packages/pandas/core/reshape/merge.py", line 73, in merge
op = _MergeOperation(
File "/home/appuser/venv/lib/python3.9/site-packages/pandas/core/reshape/merge.py", line 627, in __init__
) = self._get_merge_keys()
File "/home/appuser/venv/lib/python3.9/site-packages/pandas/core/reshape/merge.py", line 996, in _get_merge_keys
left_keys.append(left._get_label_or_level_values(lk))
File "/home/appuser/venv/lib/python3.9/site-packages/pandas/core/generic.py", line 1692, in _get_label_or_level_values
raise KeyError(key)
KeyError: 'Name'
It seems like the KeyError is coming from line 25 of my code:
df = df.merge(pd.read_csv('Venue Information.csv').rename(columns={'Venue':'Name'})[['Name','Adjusted Capacity']],on='Name').drop('Unnamed: 0',axis=1)
The code works fine locally but I am just having this issue when trying to deploy the application. Please let us know if there are any suggestions of what might be causing this. Thank you!

Why is the installation of gef on my windows giving me this error?

Traceback (most recent call last):
File "c:\msys64\mingw64\share\gdb/python\gdb\__init__.py", line 130, in _execute_file
exec(compiled, globals, globals)
File "C:\Users\AZ\gef\gef.py", line 11583, in <module>
PYTHONBIN = which("python3")
File "C:\Users\AZ\gef\gef.py", line 1738, in which
raise FileNotFoundError(f"Missing file `{program}`")
FileNotFoundError: Missing file `python3`
I cannot find solution to this error on google that's why I decided to ask here.

Anki AssertionError learning

Hi I have a problem with anki when using it I get the following error.
Anki 2.1.49 (dc80804a) Python 3.8.6 Qt 5.14.2 PyQt 5.14.2
Platform: Windows 10
Flags: frz=True ao=False sv=2
Add-ons, last update check: 2021-12-02 12:41:47
Caught exception:
Traceback (most recent call last):
File “aqt\webview.py”, line 41, in cmd
File “aqt\webview.py”, line 142, in _onCmd
File “aqt\webview.py”, line 595, in _onBridgeCmd
File “aqt\reviewer.py”, line 503, in _linkHandler
File “aqt\reviewer.py”, line 423, in _answerCard
File “aqt\reviewer.py”, line 430, in _after_answering
File “aqt\reviewer.py”, line 211, in nextCard
File “aqt\reviewer.py”, line 317, in _showQuestion
File “anki\cards.py”, line 184, in autoplay
File “anki\decks.py”, line 309, in config_dict_for_deck_id
AssertionError

AttributeError: '_UnixSelectorEventLoop' object has no attribute '_signal_handlers'

I've been upgrading our Django/Python app to Python 3.9.7 and Django 3.2.7 (from Python 3.5 and Django 1.11.23).
Currently if I try to run python manage.py createsuperuser
I get the following error
Traceback (most recent call last):
File "/Users/myuser/.pyenv/versions/3.9.7/lib/python3.9/asyncio/selector_events.py", line 261, in _add_reader
key = self._selector.get_key(fd)
File "/Users/myuser/.pyenv/versions/3.9.7/lib/python3.9/selectors.py", line 193, in get_key
raise KeyError("{!r} is not registered".format(fileobj)) from None
KeyError: '10 is not registered'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/myuser/Development/app/manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/Users/myuser/.pyenv/versions/insta9/lib/python3.9/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
utility.execute()
File "/Users/myuser/.pyenv/versions/insta9/lib/python3.9/site-packages/django/core/management/__init__.py", line 413, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/myuser/.pyenv/versions/insta9/lib/python3.9/site-packages/django/core/management/base.py", line 367, in run_from_argv
connections.close_all()
File "/Users/myuser/.pyenv/versions/insta9/lib/python3.9/site-packages/django/db/utils.py", line 213, in close_all
connection.close()
File "/Users/myuser/.pyenv/versions/insta9/lib/python3.9/site-packages/django/utils/asyncio.py", line 19, in inner
event_loop = asyncio.get_event_loop()
File "/Users/myuser/.pyenv/versions/3.9.7/lib/python3.9/asyncio/events.py", line 639, in get_event_loop
self.set_event_loop(self.new_event_loop())
File "/Users/myuser/.pyenv/versions/3.9.7/lib/python3.9/asyncio/events.py", line 659, in new_event_loop
return self._loop_factory()
File "/Users/myuser/.pyenv/versions/3.9.7/lib/python3.9/asyncio/unix_events.py", line 54, in __init__
super().__init__(selector)
File "/Users/myuser/.pyenv/versions/3.9.7/lib/python3.9/asyncio/selector_events.py", line 61, in __init__
self._make_self_pipe()
File "/Users/myuser/.pyenv/versions/3.9.7/lib/python3.9/asyncio/selector_events.py", line 112, in _make_self_pipe
self._add_reader(self._ssock.fileno(), self._read_from_self)
File "/Users/myuser/.pyenv/versions/3.9.7/lib/python3.9/asyncio/selector_events.py", line 263, in _add_reader
self._selector.register(fd, selectors.EVENT_READ,
File "/Users/myuser/.pyenv/versions/3.9.7/lib/python3.9/selectors.py", line 523, in register
self._selector.control([kev], 0, 0)
TypeError: changelist must be an iterable of select.kevent objects
Exception ignored in: <function BaseEventLoop.__del__ at 0x103307310>
Traceback (most recent call last):
File "/Users/myuser/.pyenv/versions/3.9.7/lib/python3.9/asyncio/base_events.py", line 683, in __del__
self.close()
File "/Users/myuser/.pyenv/versions/3.9.7/lib/python3.9/asyncio/unix_events.py", line 63, in close
if self._signal_handlers:
AttributeError: '_UnixSelectorEventLoop' object has no attribute '_signal_handlers'
Exception ignored in: <function BaseEventLoop.__del__ at 0x103307310>
Traceback (most recent call last):
File "/Users/myuser/.pyenv/versions/3.9.7/lib/python3.9/asyncio/base_events.py", line 683, in __del__
self.close()
File "/Users/myuser/.pyenv/versions/3.9.7/lib/python3.9/asyncio/unix_events.py", line 63, in close
if self._signal_handlers:
AttributeError: '_UnixSelectorEventLoop' object has no attribute '_signal_handlers'
These are some of the versions I'm using in my requirements.txt
Django==3.2.7
django-braces==1.14.0
django-pipeline==2.0.6
django-storages==1.11.1
djangorestframework==3.12.4
django-localflavor==2.0
django-redis==5.0.0
django_guardian==2.4.0
django-debug-toolbar==3.2.2
django-grappelli==2.15.1
django-extensions==3.1.3
django-simple-history==3.0.0
django-cities-light==3.8.1
django-autoslug==1.9.8
django-constance==2.8.0
django-jsonify==0.3.0
django-bulk-update==2.2.0
django-sslserver==0.22
django-admin-easy==0.6.1
django-admin-rangefilter==0.8.1
django-model-utils==4.1.1
gunicorn==19.7.1
honcho==0.7.1
ipython==5.6.0
eventlet==0.32.0
selenium==2.53.2
This also seems to happen when I runserver, and then kill the server again. Any ideas what could be causing the issue?
Sometimes you don't need async functionality to run the application. In that case set allow async unsafe.
export DJANGO_ALLOW_ASYNC_UNSAFE=True

Categories