keyerror

Python 3 Selenium KeyError: 'value' Issue won't initialize Geckodriver for Firefox

对着背影说爱祢 提交于 2019-12-04 13:05:16
I'm having trouble running geckodriver with Python 3. I recently switched to Python 3 with an application that I've been working on, and have updated Firefox(53.0), Selenium(3.4.3), and geckodriver(0.17.1). I'm also using OSX and used pip to install all of my packages. from selenium import webdriver from selenium.webdriver.firefox.firefox_binary import FirefoxBinary # Set Firefox Settings # binary = FirefoxBinary('Users/username/Applications/Firefox.app/Contents/MacOS/firefox') # binary = FirefoxBinary('/Applications/Firefox.app/Contents/MacOS/firefox') # binary = FirefoxBinary('/Applications

Python email bot Pyzmail/IMAPclient error

人盡茶涼 提交于 2019-12-04 12:58:05
So I'm working on a Python script to extract text from an email and following these instructions to do so. This is the script thus far: import imapclient import pprint import pyzmail mymail = "my@email.com" password = input("Password: ") imapObj = imapclient.IMAPClient('imap.gmail.com' , ssl=True) imapObj.login(mymail , password) imapObj.select_folder('INBOX', readonly=False) UIDs = imapObj.search(['SUBJECT Testing']) rawMessages = imapObj.fetch([5484], ['BODY[]']) message = pyzmail.PyzMessage.factory(rawMessages[5484]['BODY[]']) However I'm getting this error: message = pyzmail.PyzMessage

Python dictionary key error when assigning - how do I get around this?

早过忘川 提交于 2019-12-03 10:28:58
I have a dictionary that I create like this: myDict = {} Then I like to add key in it that corresponds to another dictionary, in which I put another value: myDict[2000]['hello'] = 50 So when I pass myDict[2000]['hello'] somewhere, it would give 50 . Why isn't Python just creating those entries right there? What's the issue? I thought KeyError only occurs when you try to read an entry that doesn't exist, but I'm creating it right here? KeyError occurs because you are trying to read a non-existant key when you try to access myDict[2000] . As an alternative, you could use defaultdict : >>> from

Python logging file config KeyError: 'formatters'

偶尔善良 提交于 2019-12-03 04:45:32
I'm currently working on a python project and I set up logging using a config file. It has already worked and was logging my messages as wanted. But then, after rearranging some of the packages and modules, I only get a key error. Full Traceback: Traceback (most recent call last): File "/Volumes/Daten/Eclipse/workspace/Carputer/src/pyboard/__init__.py", line 42, in <module> logging.config.fileConfig('../logging.conf', disable_existing_loggers=False) File "/opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/logging/config.py", line 70, in fileConfig formatters = _create

SQLAlchemy throwing KeyError when using Association Objects with back_populates – example from documentation doesn't work

倖福魔咒の 提交于 2019-12-02 17:40:16
问题 SQLAlchemy nicely documents how to use Association Objects with back_populates. However, when copy-and-pasting the example from that documentation, adding children to a parent throws a KeyError as following code shows. The model classes are copied 100% from the documentation: from sqlalchemy import Column, ForeignKey, Integer, String from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import relationship from sqlalchemy.schema import MetaData Base = declarative_base

Key Error when key is in dictionary

£可爱£侵袭症+ 提交于 2019-12-02 13:23:19
问题 Just trying to pull some lat/lon info from EXIF data on a bunch of photos, but code is throwing a KeyError even though that key is used (successfully) later on to print specific coordinates. Dictionary in question is " tags " - 'GPS GPSLatitude' and 'GPS GPSLongitude' are both keys in tags.keys() ; I've triple checked. So any intuition on why tags['GPS GPSLatitude'] & tags['GPS GPSLongitude'] are throwing key errors? import os import exifread output = dict() output['name'] = [] output['lon']

SQLAlchemy throwing KeyError when using Association Objects with back_populates – example from documentation doesn't work

Deadly 提交于 2019-12-02 09:35:24
SQLAlchemy nicely documents how to use Association Objects with back_populates . However, when copy-and-pasting the example from that documentation, adding children to a parent throws a KeyError as following code shows. The model classes are copied 100% from the documentation: from sqlalchemy import Column, ForeignKey, Integer, String from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import relationship from sqlalchemy.schema import MetaData Base = declarative_base(metadata=MetaData()) class Association(Base): __tablename__ = 'association' left_id = Column(Integer,

Python 3.2 logging with config file results in KeyError: 'formatters' on Raspbian

↘锁芯ラ 提交于 2019-12-02 04:36:57
I equipped my Python application with logging capability and it works flawlessly on my Windows system with Python 3.4. But when I deploy the application on my Raspberry Pi with Raspbian and Python 3.2, I receive the following error: Traceback (most recent call last): File "aurora/aurora_websocket.py", line 265, in <module> logging.config.fileConfig('logging.conf') File "/usr/lib/python3.2/logging/config.py", line 70, in fileConfig formatters = _create_formatters(cp) File "/usr/lib/python3.2/logging/config.py", line 106, in _create_formatters flist = cp["formatters"]["keys"] File "/usr/lib

Key Error when key is in dictionary

主宰稳场 提交于 2019-12-02 04:24:42
Just trying to pull some lat/lon info from EXIF data on a bunch of photos, but code is throwing a KeyError even though that key is used (successfully) later on to print specific coordinates. Dictionary in question is " tags " - 'GPS GPSLatitude' and 'GPS GPSLongitude' are both keys in tags.keys() ; I've triple checked. So any intuition on why tags['GPS GPSLatitude'] & tags['GPS GPSLongitude'] are throwing key errors? import os import exifread output = dict() output['name'] = [] output['lon'] = [] output['lat'] = [] for file in os.listdir(path): if file.endswith(".JPG"): full_path = path + file

Dict KeyError for value in the dict

我怕爱的太早我们不能终老 提交于 2019-12-01 22:47:35
问题 I have a dict inside a dict: { '123456789': {u'PhoneOwner': u'Bob', 'Frequency': 0}, '98765431': {u'PhoneOwner': u'Sarah', 'Frequency': 0}, } The idea is to scan a list of calls made by numbers and compare against the dict, increasing the frequency each time a match is found. When I run the script: try: phoneNumberDictionary[int(line)]['Frequency'] += 1 except KeyError: phoneNumberDictionary[int(line)]['Frequency'] = 1 I get error: KeyError: '18667209918' (Where 18667209918 is the number that