55

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
terdon
  • 98,183
  • 15
  • 197
  • 293
Niklas
  • 711
  • 1
  • 5
  • 9
  • http://meta.askubuntu.com/questions/15739/eol-notice-wily-werewolf-15-10-will-be-eol-on-july-28-2016?cb=1: I recommend updating to 16.04. – anonymous2 Jul 11 '16 at 12:01

3 Answers3

82

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

grooveplex
  • 2,486
  • 3
  • 25
  • 35
71
»» fatal error: openssl/opensslv.h: No such file or directory ««

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

Knud Larsen
  • 3,044
  • 2
  • 12
  • 13
  • I did receive the same error during the setup of pyOpenSSL in Ubuntu 16.04 (inside a python virtualenv). This answer solved my problem. Thanks – yucer Sep 14 '16 at 12:53
  • fixed issue when installing "pip install fabric" on Ubuntu server (stretch/sid or Ubuntu 16.04.1 LTS). – Sergei G Mar 15 '17 at 22:21
  • 1
    This is the simple clean answer for anything that relies on https://pypi.python.org/pypi/cryptography/1.8.1 for instance https://pypi.python.org/pypi/paramiko/2.1.2 – Bruno Bronosky Mar 16 '17 at 00:39
  • 1
    Saved the error while installing hashpumpy. – NonStandardModel May 29 '18 at 20:28
  • I had a similar issue trying to install `keyring` on `alpine`, but got `ERROR: unsatisfiable constraints` when trying to install `libssl-dev`. Was able to solve it by installing `openssl-dev` instead. – cowlinator Jan 11 '19 at 01:58
  • I have two follow-on questions: a) how would one have been able to determine, without StackOverflow, that `libssl-dev` was the right thing to install? b) why isn't that installed as a dependency of `mitmproxy` (I guess because it's not installable via pip? Why not?)? – scubbo Dec 31 '20 at 01:51
  • @scubbo : `pip` is installing python code only. `openssl → libopenssl` is C code https://packages.ubuntu.com/focal-updates/libssl-dev → → https://packages.ubuntu.com/source/focal-updates/openssl – Knud Larsen Dec 31 '20 at 09:26
  • So why is the installation of a Python library silently and implicitly depending on something that isn't a Python library, and providing an error message that requires further context to resolve? I'm sure that there are very good legacy reasons, but is that "something that should continue to be true", or "something that happens to be most-convenient and good-enough now, but would not be the case in a perfect world"? (EDIT: to be clear - I'm not aggressively saying "this is wrong", I'm saying "this _feels_ wrong to me, but I know enough to know that I know nothing - what am I missing?") – scubbo Jan 02 '21 at 01:32
  • scubbo : You have to observe the `pip` install sequence to know that **pip** is building from source code = https://pypi.org/project/pip/ → → https://pypi.org/project/pip/#files – Knud Larsen Jan 03 '21 at 10:38
4

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.

Thomas Ward
  • 72,494
  • 30
  • 173
  • 237