How to install Python MySQLdb module using pip?

It’s easy to do, but hard to remember the correct spelling: If you need 1.2.x versions (legacy Python only), use pip install MySQL-python Note: Some dependencies might have to be in place when running the above command. Some hints on how to install these on various platforms: Ubuntu 14, Ubuntu 16, Debian 8.6 (jessie) Fedora … Read more

Python Add to dictionary loop

This function is supposed to add a name and number to the dictionary ‘phoneBook’ when I run the loop, but for some reason I can’t get it to work. Any ideas on why not? Thanks a lot!

Repeated “Kernel died, restarting” forever

When I attempt to run The console shows up, with the message Which continues. Trying $ jupyter qtconsole –debug didn’t print anything else, and neither has adding into $USERHOME/.jupyter/jupyter_qtconsole_config.py Also, I found nothing in $USERHOME/.ipython/profile_default/log/ and the other directories around there. Nothing has changed in my configuration since last time I started up jupyter-qtconsole. How … Read more

How to create a numpy array of lists?

As you discovered, np.array tries to create a 2d array when given something like You have apply some tricks to get around this default behavior. One is to make the sublists variable in length. It can’t make a 2d array from these, so it resorts to the object array: And you can then append values … Read more

python math domain errors in math.log function

As long as your input is within the half-open interval (0, 1] (not including 0), you are fine. You can’t be too close to zero: So simply checking for exactly zero (maybe as the result of an underflow) should be enough, or alternatively catch the exception and handle it. EDIT: This also holds for the … Read more