 <p>Ok, I found the answer. csl's answer set me on the right path.</p> <p>pexpect has a "env" option which I thought I could use. like this:</p> <pre><code>a = pexpect.spawn('program', env = {"TERM": "dumb"}) </code></pre> <p>But this spawns a new shell which does not work for me, our development environment depends on a lot of environmental variables :/</p> <p>But if I do this before spawning a shell:</p> <pre><code>import os os.environ["TERM"] = "dumb" </code></pre> <p>I change the current "TERM" and "dumb" does not support colours, which fixed my issue.</p>