# How to install the latest mitmproxy from PyPI



## getopt (Jan 25, 2017)

Why not install mitmproxy from ports?

As of today www/mitmproxy still is on mitmproxy-0.15 (this might change hopefully) which does not work since summer 2016. Meanwhile mitmproxy moved from Python2 to Python3 and the latest version now is mitmproxy-1.0.2.

Python3 can be installed along with Python2 without any interference. In this case you can have py2-ports from the ports-tree and p3-apps from the the Python Package Index (PyPi).

Proxies are typically best run in a jail. So create a jail first for mitmproxy and do the installation there. With a dedicated jail you won't have any interference even with possible py3-ports on your host.

So here we go:

```
mitm-jail# pkg install python3
mitm-jail# rehash
mitm-jail# python3 -m ensurepip
mitm-jail# rehash
mitm-jail# pip install mitmproxy
mitm-jail# rehash
```
Hint: If you have an old .mitmproxy, delete the certificates there as they are probably obsolete. Old certificates prevent mitmproxy to create new ones, if exist.

Now start `#  mitmproxy` and new certificates are created on the first run.

On the jail-host do `# sockstat -l` and find something like this:

```
# sockstat -l
USER     COMMAND    PID   FD PROTO  LOCAL ADDRESS         FOREIGN ADDRESS    
root     python3.5  7749  4  tcp4   xxx.xxx.xxx.xxx:8080     *:*
```
indicating that mitmproxy is ready listening.

For further steps follow http://docs.mitmproxy.org/en/latest/mitmproxy.html depending on your needs.

Don't forget to import the mitmproxy-certificate to your browser's certificates and enjoy.


----------

