# Trying to import mitmproxy into python3 project

**URL:** https://discourse.mitmproxy.org/t/trying-to-import-mitmproxy-into-python3-project/171
**Category:** help
**Created:** [September 15, 2016, 9:36pm UTC](https://discourse.mitmproxy.org/t/trying-to-import-mitmproxy-into-python3-project/171 "2016-09-15T21:36:36Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![blahblahuser](https://avatars.discourse-cdn.com/v4/letter/b/f475e1/32.png) [@blahblahuser](https://discourse.mitmproxy.org/u/blahblahuser)
#### Post date: [September 15, 2016, 9:36pm UTC](https://discourse.mitmproxy.org/t/trying-to-import-mitmproxy-into-python3-project/171/1 "2016-09-15T21:36:36Z")

</div>

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,

---

<div class="post-metadata">

### Author: ![mhils](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mitmproxy.org/mhils/32/7_2.png) [@mhils](https://discourse.mitmproxy.org/u/mhils)
#### Post date: [September 15, 2016, 10:34pm UTC](https://discourse.mitmproxy.org/t/trying-to-import-mitmproxy-into-python3-project/171/2 "2016-09-15T22:34:41Z")

</div>

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. 🙂

---

<div class="post-metadata">

### Author: ![blahblahuser](https://avatars.discourse-cdn.com/v4/letter/b/f475e1/32.png) [@blahblahuser](https://discourse.mitmproxy.org/u/blahblahuser)
#### Post date: [September 15, 2016, 11:24pm UTC](https://discourse.mitmproxy.org/t/trying-to-import-mitmproxy-into-python3-project/171/3 "2016-09-15T23:24:01Z")

</div>

@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",
```

---

<div class="post-metadata">

### Author: ![mhils](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mitmproxy.org/mhils/32/7_2.png) [@mhils](https://discourse.mitmproxy.org/u/mhils)
#### Post date: [September 26, 2016, 2:41am UTC](https://discourse.mitmproxy.org/t/trying-to-import-mitmproxy-into-python3-project/171/4 "2016-09-26T02:41:02Z")

</div>

@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](http://docs.mitmproxy.org/en/stable/install.html) should cover everything. 🙂

---

<div class="post-metadata">

### Author: ![blahblahuser](https://avatars.discourse-cdn.com/v4/letter/b/f475e1/32.png) [@blahblahuser](https://discourse.mitmproxy.org/u/blahblahuser)
#### Post date: [September 27, 2016, 10:00pm UTC](https://discourse.mitmproxy.org/t/trying-to-import-mitmproxy-into-python3-project/171/5 "2016-09-27T22:00:31Z")

</div>

@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
```

---

<div class="post-metadata">

### Author: ![mhils](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mitmproxy.org/mhils/32/7_2.png) [@mhils](https://discourse.mitmproxy.org/u/mhils)
#### Post date: [September 29, 2016, 1:43am UTC](https://discourse.mitmproxy.org/t/trying-to-import-mitmproxy-into-python3-project/171/6 "2016-09-29T01:43:23Z")

</div>

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