Trying to import mitmproxy into python3 project

Hi There,

We are trying to use mitmproxy for our internal testing tool which written in Python3.
Then I do from mitmproxy import flow it doesn work( not importing) We are -reusing flow.FlowReader part .
Can you please help and advice how can we setup mitm with python3 for development.
If I do pip install mitmproxy its installing/importing only mitm.0.15. Is it a way, hack it so we can use it ?

I’m not sure is it a clear question , but basically if I have line like this : from mitmproxy import flow python will throw an ImportError.

Thank you,

The first version to support Python 3 will be 0.18. We’re somewhat close to a release, but you’d need to use the master branch for now. :slight_smile:

@mhils thank you for a quick response. Can I just ask for quick clarification to setting this up.
I clonned master mitm in my project. I run python3 setup.py install .
my python version is 3.5.2
But I’m getting a huge stack trace message . Like below :

        File "/var/folders/7b/kg453htd1pl5v_cv691p546h0000gn/T/easy_install-6c2f1s5g/Pillow-3.3.1/setup.py", line 521, in build_extensions
        ValueError: jpeg is required unless explicitly disabled using --disable-jpeg, aborting

        During handling of the above exception, another exception occurred:

        Traceback (most recent call last):
          File "setup.py", line 123, in <module>
            "pytz>=2015.07.0, <=2016.6.1",

@blahblahuser: You are missing dependencies from Pillow, if you google the ValueError: jpeg is required unless explicitly disabled using --disable-jpeg you should find what you need. The dependencies mentioned on http://docs.mitmproxy.org/en/stable/install.html should cover everything. :slight_smile:

@mhils thank you I 've fixed , should have close this question .
But today I’m trying to setup Dockerfile and running into the error
on ubuntu:trusty by running a python3 setup.py install :

x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC -c _configtest.c -o _configtest.o
success!
removing: _configtest.c _configtest.o
c/_cffi_backend.c:15:17: fatal error: ffi.h: No such file or directory
 #include <ffi.h>
                 ^
compilation terminated.
error: Setup script exited with error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
root@6fd0a0da7199:/home/mitmproxy# mitmproxy
Traceback (most recent call last):
  File "/usr/local/bin/mitmproxy", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2749, in <module>
    working_set = WorkingSet._build_master()
  File "/usr/lib/python3/dist-packages/pkg_resources.py", line 444, in _build_master
    ws.require(__requires__)
  File "/usr/lib/python3/dist-packages/pkg_resources.py", line 725, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/lib/python3/dist-packages/pkg_resources.py", line 628, in resolve
    raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: brotlipy>=0.5.1,<0.7

You are missing dependencies. Check our install section in the docs. :slight_smile: