keyerror 1 in my code

Your main problem is this line: You think you’re making a copy of the dictionary, but actually you still have just one dictionary, so operations on dicta also change aDict (and so, you remove values from adict, they also get removed from aDict, and so you get your KeyError). One solution would be (You should … Read more

xlrd.biffh.XLRDError: Excel xlsx file; not supported

As noted in the release email, linked to from the release tweet and noted in large orange warning that appears on the front page of the documentation, and less orange, but still present, in the readme on the repository and the release on pypi: xlrd has explicitly removed support for anything other than xls files. In your case, the solution is to: … Read more

How to print to console in pytest?

By default, py.test captures the result of standard out so that it can control how it prints it out. If it didn’t do this, it would spew out a lot of text without the context of what test printed that text. However, if a test fails, it will include a section in the resulting report that shows … Read more

Running Selenium with Headless Chrome Webdriver

To run chrome-headless just add –headless via chrome_options.add_argument, i.e.: So my thought is that running it with headless chrome would make my script faster. Try using chrome options like –disable-extensions or –disable-gpu and benchmark it, but I wouldn’t count with much improvement. References: headless-chrome Note: As of today, when running chrome headless on Windows., you should include the  –disable-gpu flag See crbug.com/737678

How can I rename a conda environment?

You can’t. One workaround is to create clone a new environment and then remove the original one. First, remember to deactivate your current environment. You can do this with the commands: deactivate on Windows or source deactivate on macOS/Linux. Then: Notice there are several drawbacks of this method: It redownloads packages (you can use –offline flag to disable it) Time consumed on copying … Read more

How to print a dictionary’s key?

A dictionary has, by definition, an arbitrary number of keys. There is no “the key”. You have the keys() method, which gives you a python list of all the keys, and you have the iteritems() method, which returns key-value pairs, so Python 3 version: So you have a handle on the keys, but they only really mean sense if coupled to … Read more