# \[SOLVED\] Python scripts: Errors importing other modules

**URL:** https://discourse.mitmproxy.org/t/solved-python-scripts-errors-importing-other-modules/650
**Category:** help
**Created:** [October 10, 2017, 6:13pm UTC](https://discourse.mitmproxy.org/t/solved-python-scripts-errors-importing-other-modules/650 "2017-10-10T18:13:01Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![teward](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mitmproxy.org/teward/32/213_2.png) [@teward](https://discourse.mitmproxy.org/u/teward)
#### Post date: [October 10, 2017, 6:13pm UTC](https://discourse.mitmproxy.org/t/solved-python-scripts-errors-importing-other-modules/650/1 "2017-10-10T18:13:02Z")

</div>

I’ve got an odd issue.

Firstly, this worked _fine_ yesterday (maybe I need to reboot?). Now, it’s just failing hard and not properly operating as I need it to.

I’ve got a script, called `rewrite_destination_server.py`, which interfaces with an SQLite3 database, and pulls out data regarding regex pattern matches for a given host and then determine what to actually _do_ for each request that comes through mitmproxy.

Essentially, upon script loading, it pulls data from the SQLite database, populates an internally-stored dict, and then uses that dict, regexpatterns, and other items in order to determine what web server to _actually_ route a request through.

For example, if the regex pattern is `(\w.\.)?example.com`, and it has in the SQL row to redirect to `localhost` on port 80, but keep the same `Host` header, then it sends a request to `http://localhost:80/` requesting the originally requested host for any \*.example.com domain (including just [example.com](http://example.com)).

This script worked _fine_ yesterday, and I haven’t made any system level changes. Problem is, `mitmproxy` when it loads the script can no longer can find the proper modules, and gives me an ImportError on `import sqlite3`.

I’m using the MITMProxy 2.0.2 binaries that were built for Linux; is it possible this is the problem and I need to do a from-soruce compile?

---

<div class="post-metadata">

### Author: ![teward](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mitmproxy.org/teward/32/213_2.png) [@teward](https://discourse.mitmproxy.org/u/teward)
#### Post date: [October 10, 2017, 6:14pm UTC](https://discourse.mitmproxy.org/t/solved-python-scripts-errors-importing-other-modules/650/2 "2017-10-10T18:14:47Z")

</div>

WOW I’m an idiot.

It looks like adding a shebang line, `#!/usr/bin/python3`, to each of the scripts properly fixes the ImportError problems…

I feel stupid/silly now. Sorry for bothering you all.
