Skip to content

Tag: python

error installing nltk supporting packages : nltk.download()

I have installed the nltk package. Following that I am trying to download the supporting packages using nltk.download() and am getting error: [Errno 11001] getaddrinfo My machine / software details are: OS: Windows 8.1 Python: 3.3.4 NLTK Package: 3.0 Below are the commands run in python: It looks like it is g…

How to save a list to a file and read it as a list type?

Say I have the list score = [1,2,3,4,5] and it gets changed while my program is running. How could I save it to a file so that next time the program is run I can access the changed list as a list type? I have tried: But this results in the elements in the list being strings not integers. Answer

Sending MIDI messages using Python (on Ubuntu)

I am trying to send a basic MIDI message to a synthesizer, using Python. I know that the PC-Synthesizer link is functional because the Rosegarden application can be configured to play MIDI files on the device, when the MIDI output is set to ‘DigitalKBD 20:0’ port. I have discovered this Python lib…

Hide traceback unless a debug flag is set

What is the idiomatic python way to hide traceback errors unless a verbose or debug flag is set? Example code: Existing output now, but only desired when called with foo.py –debug: Desired normal output: Here’s a test script: https://gist.github.com/maphew/e3a75c147cca98019cd8 Answer The short way…

GtkWarning: could not open display

I am trying to run a spider on a vps (using scrapyjs which uses python-gtk2). On running the spider I am getting the error How do I run this in a headless setup? Answer First of all, you didn’t specify if you have a desktop environment (or X) installed on your server? Regardless of that, you can achieve…