Can't install mitmproxy on El Capitan 10.11.6

Hi all,

I am having some issues with installing mitmproxy on El Capitan 10.11.6

Is this a known issue? Please advise. I haven’t found a solution on Google yet.

$ sudo pip install mitmproxy
The directory ‘/Users/kelvin/Library/Caches/pip/http’ or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo’s -H flag.
The directory ‘/Users/kelvin/Library/Caches/pip’ or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo’s -H flag.
Collecting mitmproxy
Downloading mitmproxy-0.18.2-py2.py3-none-any.whl (1.4MB)
100% |████████████████████████████████| 1.4MB 1.0MB/s
Requirement already satisfied: certifi>=2015.11.20.1 in /Library/Python/2.7/site-packages (from mitmproxy)
Requirement already satisfied: backports.ssl-match-hostname<3.6,>=3.5.0.1 in /Library/Python/2.7/site-packages (from mitmproxy)
Collecting passlib<1.7,>=1.6.5 (from mitmproxy)
Downloading passlib-1.6.5-py2.py3-none-any.whl (317kB)
100% |████████████████████████████████| 327kB 3.2MB/s
Collecting six<1.11,>=1.10 (from mitmproxy)
Downloading six-1.10.0-py2.py3-none-any.whl
Requirement already satisfied: pyasn1<0.2,>=0.1.9 in /Library/Python/2.7/site-packages (from mitmproxy)
Collecting cssutils<1.1,>=1.0.1 (from mitmproxy)
Downloading cssutils-1.0.1-py2-none-any.whl (292kB)
100% |████████████████████████████████| 296kB 4.5MB/s
Collecting hyperframe<5,>=4.0.1 (from mitmproxy)
Downloading hyperframe-4.0.1-py2.py3-none-any.whl
Collecting jsbeautifier<1.7,>=1.6.3 (from mitmproxy)
Downloading jsbeautifier-1.6.4.tar.gz (51kB)
100% |████████████████████████████████| 51kB 5.3MB/s
Collecting tornado<4.5,>=4.3 (from mitmproxy)
Downloading tornado-4.4.2.tar.gz (460kB)
100% |████████████████████████████████| 460kB 2.5MB/s
Collecting pyperclip<1.6,>=1.5.22 (from mitmproxy)
Downloading pyperclip-1.5.27.zip
Collecting cryptography<1.6,>=1.3 (from mitmproxy)
Downloading cryptography-1.5.3-cp27-cp27m-macosx_10_10_intel.whl (2.4MB)
100% |████████████████████████████████| 2.4MB 619kB/s
Collecting pyparsing<2.2,>=2.1.3 (from mitmproxy)
Downloading pyparsing-2.1.10-py2.py3-none-any.whl (56kB)
100% |████████████████████████████████| 61kB 7.3MB/s
Collecting blinker<1.5,>=1.4 (from mitmproxy)
Downloading blinker-1.4.tar.gz (111kB)
100% |████████████████████████████████| 112kB 5.8MB/s
Collecting brotlipy<0.7,>=0.5.1 (from mitmproxy)
Downloading brotlipy-0.6.0-cp27-cp27m-macosx_10_6_intel.whl (656kB)
100% |████████████████████████████████| 665kB 2.0MB/s
Collecting pyOpenSSL<17.0,>=16.0 (from mitmproxy)
Downloading pyOpenSSL-16.2.0-py2.py3-none-any.whl (43kB)
100% |████████████████████████████████| 51kB 6.0MB/s
Collecting urwid<1.4,>=1.3.1 (from mitmproxy)
Downloading urwid-1.3.1.tar.gz (588kB)
100% |████████████████████████████████| 593kB 2.3MB/s
Collecting click<7.0,>=6.2 (from mitmproxy)
Downloading click-6.6-py2.py3-none-any.whl (71kB)
100% |████████████████████████████████| 71kB 7.6MB/s
Collecting ipaddress<1.1,>=1.0.15; python_version == “2.7” (from mitmproxy)
Downloading ipaddress-1.0.17-py2-none-any.whl
Collecting Flask<0.12,>=0.10.1 (from mitmproxy)
Downloading Flask-0.11.1-py2.py3-none-any.whl (80kB)
100% |████████████████████████████████| 81kB 7.1MB/s
Collecting enum34<2,>=1.0.4; python_version == “2.7” (from mitmproxy)
Downloading enum34-1.1.6-py2-none-any.whl
Collecting configargparse<0.12,>=0.10 (from mitmproxy)
Downloading ConfigArgParse-0.11.0.tar.gz (40kB)
100% |████████████████████████████████| 40kB 7.8MB/s
Collecting typing==3.5.2.2; python_version == “2.7” (from mitmproxy)
Downloading typing-3.5.2.2.tar.gz (51kB)
100% |████████████████████████████████| 51kB 3.3MB/s
Collecting h2<2.5,>=2.4.1 (from mitmproxy)
Downloading h2-2.4.2-py2.py3-none-any.whl (54kB)
100% |████████████████████████████████| 61kB 8.5MB/s
Collecting html2text<=2016.9.19,>=2016.1.8 (from mitmproxy)
Downloading html2text-2016.9.19.tar.gz (47kB)
100% |████████████████████████████████| 51kB 7.6MB/s
Collecting requests<2.12,>=2.9.1 (from mitmproxy)
Downloading requests-2.11.1-py2.py3-none-any.whl (514kB)
100% |████████████████████████████████| 522kB 2.4MB/s
Collecting construct<2.6,>=2.5.2 (from mitmproxy)
Downloading construct-2.5.3.tar.gz (688kB)
100% |████████████████████████████████| 696kB 1.8MB/s
Collecting Pillow<3.5,>=3.2 (from mitmproxy)
Downloading Pillow-3.4.2-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (3.4MB)
100% |████████████████████████████████| 3.5MB 420kB/s
Collecting watchdog<0.9,>=0.8.3 (from mitmproxy)
Downloading watchdog-0.8.3.tar.gz (83kB)
100% |████████████████████████████████| 92kB 7.8MB/s
Collecting lxml<=3.6.0,>=3.5.0 (from mitmproxy)
Downloading lxml-3.6.0.tar.gz (3.7MB)
100% |████████████████████████████████| 3.7MB 407kB/s
Collecting editorconfig>=0.12.0 (from jsbeautifier<1.7,>=1.6.3->mitmproxy)
Downloading EditorConfig-0.12.1.tar.gz
Collecting singledispatch (from tornado<4.5,>=4.3->mitmproxy)
Downloading singledispatch-3.4.0.3-py2.py3-none-any.whl
Collecting backports_abc>=0.4 (from tornado<4.5,>=4.3->mitmproxy)
Downloading backports_abc-0.5-py2.py3-none-any.whl
Collecting cffi>=1.4.1 (from cryptography<1.6,>=1.3->mitmproxy)
Downloading cffi-1.9.1-cp27-cp27m-macosx_10_10_intel.whl (214kB)
100% |████████████████████████████████| 215kB 4.8MB/s
Collecting setuptools>=11.3 (from cryptography<1.6,>=1.3->mitmproxy)
Downloading setuptools-31.0.0-py2.py3-none-any.whl (477kB)
100% |████████████████████████████████| 481kB 2.2MB/s
Requirement already satisfied: idna>=2.0 in /Library/Python/2.7/site-packages (from cryptography<1.6,>=1.3->mitmproxy)
Collecting itsdangerous>=0.21 (from Flask<0.12,>=0.10.1->mitmproxy)
Downloading itsdangerous-0.24.tar.gz (46kB)
100% |████████████████████████████████| 51kB 3.2MB/s
Collecting Werkzeug>=0.7 (from Flask<0.12,>=0.10.1->mitmproxy)
Downloading Werkzeug-0.11.11-py2.py3-none-any.whl (306kB)
100% |████████████████████████████████| 307kB 2.1MB/s
Collecting Jinja2>=2.4 (from Flask<0.12,>=0.10.1->mitmproxy)
Downloading Jinja2-2.8-py2.py3-none-any.whl (263kB)
100% |████████████████████████████████| 266kB 6.0MB/s
Collecting hpack<3,>=2.2 (from h2<2.5,>=2.4.1->mitmproxy)
Downloading hpack-2.3.0-py2.py3-none-any.whl
Collecting PyYAML>=3.10 (from watchdog<0.9,>=0.8.3->mitmproxy)
Downloading PyYAML-3.12.tar.gz (253kB)
100% |████████████████████████████████| 256kB 3.4MB/s
Collecting argh>=0.24.1 (from watchdog<0.9,>=0.8.3->mitmproxy)
Downloading argh-0.26.2-py2.py3-none-any.whl
Collecting pathtools>=0.1.1 (from watchdog<0.9,>=0.8.3->mitmproxy)
Downloading pathtools-0.1.2.tar.gz
Collecting pycparser (from cffi>=1.4.1->cryptography<1.6,>=1.3->mitmproxy)
Downloading pycparser-2.17.tar.gz (231kB)
100% |████████████████████████████████| 235kB 5.2MB/s
Collecting MarkupSafe (from Jinja2>=2.4->Flask<0.12,>=0.10.1->mitmproxy)
Downloading MarkupSafe-0.23.tar.gz
Installing collected packages: passlib, six, cssutils, hyperframe, editorconfig, jsbeautifier, singledispatch, backports-abc, tornado, pyperclip, pycparser, cffi, setuptools, ipaddress, enum34, cryptography, pyparsing, blinker, brotlipy, pyOpenSSL, urwid, click, itsdangerous, Werkzeug, MarkupSafe, Jinja2, Flask, configargparse, typing, hpack, h2, html2text, requests, construct, Pillow, PyYAML, argh, pathtools, watchdog, lxml, mitmproxy
Found existing installation: six 1.4.1
DEPRECATION: Uninstalling a distutils installed project (six) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.
Uninstalling six-1.4.1:
Exception:
Traceback (most recent call last):
File “/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/basecommand.py”, line 215, in main
status = self.run(options, args)
File “/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/commands/install.py”, line 342, in run
prefix=options.prefix_path,
File “/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_set.py”, line 778, in install
requirement.uninstall(auto_confirm=True)
File “/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py”, line 754, in uninstall
paths_to_remove.remove(auto_confirm)
File “/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_uninstall.py”, line 115, in remove
renames(path, new_path)
File “/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/utils/init.py”, line 267, in renames
shutil.move(old, new)
File “/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py”, line 302, in move
copy2(src, real_dst)
File “/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py”, line 131, in copy2
copystat(src, dst)
File “/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py”, line 103, in copystat
os.chflags(dst, st.st_flags)
OSError: [Errno 1] Operation not permitted: ‘/tmp/pip-RGBHxE-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six-1.4.1-py2.7.egg-info’

I managed to fix the issue from another post on Stack Exchange.

However, I am faced with the below issue now. Any ideas?

$ mitmproxy
Traceback (most recent call last):
File “/usr/local/bin/mitmproxy”, line 7, in
from mitmproxy.main import mitmproxy
File “/Library/Python/2.7/site-packages/mitmproxy/main.py”, line 7, in
from six.moves import _thread # PY3: We only need _thread.error, which is an alias of RuntimeError in 3.3+
ImportError: cannot import name _thread