Accessing mosquitto broker from python paho.mqtt.client

I am unable to connect to mosquitto broker from Python. I can do it from command line using mosquitto_pub/sub. However, not from Python. Is there some form of a sandbox that you run Python scripts in?

I can run the test file from 3 other machines, that have mosquitto broker installed and running with default settings.

My circle.yml:
machine:
python:
version: 2.7.12

dependencies:
pre:
- sudo apt-get update
- sudo apt-get install mosquitto mosquitto-clients
- sudo service mosquitto status

My python test file:
import paho.mqtt.client as mqtt

def on_log(client, userdata, level, buf):
print("log: ", buf)

def on_connect(client, userdata, flag, rc):
print(‘connected’)
m = c.publish(“house/bulbs/bulb1”, “OFF”)
print(m.is_published())

c = mqtt.Client()
c.on_log = on_log
c.on_connect = on_connect
assert (c.connect(‘localhost’, 1883) == 0)
c.loop_forever()