Use mitmproxy with PyInstaller


#1

Hello everyone!

I’m trying to use mitmproxy in a Python 3 app that I’m building, but after packaging with PyInstaller, I get this error when running the app on the Mac:

ValueError: dataPath: mitmproxy/addons/onboardingapp/templates does not exist.

I’m I missing something in the PyInstaller spec?

I only found this post from 2016 but I don’t understand it ;(

Thank you for the help and the awesome OSS project!
Tiago


#2

The problem only happens when importing:
import mitmproxy.tools.dump

In order to use:
m = mitmproxy.tools.dump.DumpMaster(opts)


#3

I was able to package the app with this workaround:

  1. Importing the mitmproxy like this:
import mitmproxy
import mitmproxy.options
import mitmproxy.proxy
import mitmproxy.tools
import mitmproxy.tools.dump
  1. Importing configparser:

import configparser

  1. After packaging copying the directory mitmproxy into ./dist/MyApp.app/Contents/MacOS/