"fatal error: openssl/opensslv.h: No such file or directory" compiling mitmproxy

I'm trying to install the mitmproxy package via pip like this:

$ sudo pip install mitmproxy

It terminates with following error message:

x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c build/temp.linux-x86_64-2.7/_openssl.c -o build/temp.linux-x86_64-2.7/build/temp.linux-x86_64-2.7/_openssl.o

build/temp.linux-x86_64-2.7/_openssl.c:391:30: fatal error: openssl/opensslv.h: No such file or directory

compilation terminated.

error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

----------------------------------------
  Can't roll back cryptography; was not uninstalled
Cleaning up...
Command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-jvLTVf/cryptography/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-DrY4DI-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip-build-jvLTVf/cryptography
Storing debug log for failure in /home/niklas/.pip/pip.log

After this it's somewhat installed, at least I can uninstall it afterwards.

 $ mitmproxy

leads to

Traceback (most recent call last):
  File "/usr/local/bin/mitmproxy", line 7, in <module>
    from mitmproxy.main import mitmproxy
  File "/usr/local/lib/python2.7/dist-packages/mitmproxy/main.py", line 7, in <module>
    from . import version, cmdline
  File "/usr/local/lib/python2.7/dist-packages/mitmproxy/cmdline.py", line 6, in <module>
    import configargparse
ImportError: No module named configargparse

The other answers only address the dependencies to make the errors you mentioned go away. The list of all dependencies needed is actually much longer.

You can install them all with:

sudo apt-get install python-pip python-dev libffi-dev libssl-dev libxml2-dev libxslt1-dev libjpeg8-dev zlib1g-dev

Then you can install mitmproxy:

sudo pip install mitmproxy

And run it:

mitmproxy

Source: the documentation


»» fatal error: openssl/opensslv.h: No such file or directory ««

Install openssl : sudo apt-get update && sudo apt-get install libssl-dev


There's actually two different issues here in your output (assuming all other dependency issues are resolved already). Both need fixed.

Missing SSL Libraries

  1. As was stated by Knud Larsen in their answer to this question, you are missing the OpenSSL libraries. Refer to their answer on this question for that issue.

Missing Python Modules

  1. There is a python script that is part of whatever you're running, and it is missing a module (called configargparse) which it needs to run.

    If you are on Ubuntu 15.10 or newer, you can install it by doing sudo apt-get install python-configargparse.

    If you are on any version of Ubuntu before 15.10 you will need to install it via pip to download it and make it available to the system: sudo pip install configargparse

    (Note that python pip install mitmproxy will achieve the same type of dependency resolutions once you fix the missing SSL libraries issue, however if it does not for some reason you'll have to manually install that module)

NOTE: Your question states that you are using Ubuntu MATE 15.10. Ubuntu 15.10 for all variants has gone EndOfLife on July 28, 2016. You should consider upgrading to 16.04, in order to receive continued Ubuntu support and updates.