1

I am having following issue when installing mitmproxy through pip. I have tried other fixed related to egg error. Here on stack overflow. Can't install via pip because of egg_info error pip install matplotlib fails: 'cannot build package freetype; "python setup.py egg_info" failed with error code 1'

104:bin user129856$ sudo pip install mitmproxy
The directory '/Users/alokchoudhary/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/alokchoudhary/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.
Collecting mitmproxy
/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
  Downloading mitmproxy-0.12.1.tar.gz (6.5MB)
    100% |████████████████████████████████| 6.5MB 18kB/s 
Collecting pyperclip>=1.5.8 (from mitmproxy)
  Downloading pyperclip-1.5.11.zip
Collecting pyasn1>0.1.2 (from mitmproxy)
  Downloading pyasn1-0.1.8.tar.gz (75kB)
    100% |████████████████████████████████| 77kB 827kB/s 
Collecting tornado>=4.0.2 (from mitmproxy)
  Downloading tornado-4.2.tar.gz (433kB)
    100% |████████████████████████████████| 434kB 260kB/s 
Collecting lxml>=3.3.6 (from mitmproxy)
  Downloading lxml-3.4.4.tar.gz (3.5MB)
    100% |████████████████████████████████| 3.5MB 32kB/s 
Collecting netlib<0.13,>=0.12 (from mitmproxy)
  Downloading netlib-0.12.1.tar.gz (64kB)
    100% |████████████████████████████████| 65kB 729kB/s 
    Complete output from command python setup.py egg_info:
    warning: no files found matching 'OpenSSL/RATIONALE'
    warning: no previously-included files found matching 'leakcheck'
    warning: no previously-included files matching '*.py' found under directory 'leakcheck'
    warning: no previously-included files matching '*.pem' found under directory 'leakcheck'
    warning: no previously-included files matching '*.pyc' found anywhere in distribution
    no previously-included directories found matching 'doc/_build'
    zip_safe flag not set; analyzing archive contents...

    Installed /private/tmp/pip-build-wOHXdq/netlib/.eggs/pyOpenSSL-0.15.1-py2.7.egg
    Searching for cffi
    Reading https://pypi.python.org/simple/cffi/
    Best match: cffi 1.1.2
    Downloading https://pypi.python.org/packages/source/c/cffi/cffi-1.1.2.tar.gz#md5=ca6e6c45b45caa87aee9adc7c796eaea
    Processing cffi-1.1.2.tar.gz
    Writing /tmp/easy_install-_e2qwn/cffi-1.1.2/setup.cfg
    Running cffi-1.1.2/setup.py -q bdist_egg --dist-dir /tmp/easy_install-_e2qwn/cffi-1.1.2/egg-dist-tmp-382ExN
    c/_cffi_backend.c:13:10: fatal error: 'ffi.h' file not found
    #include <ffi.h>
             ^
    1 error generated.
    Traceback (most recent call last):
      File "<string>", line 20, in <module>
      File "/private/tmp/pip-build-wOHXdq/netlib/setup.py", line 87, in <module>
        "install": CFFIInstall,
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 112, in setup
        _setup_distribution = dist = klass(attrs)
      File "build/bdist.macosx-10.10-intel/egg/setuptools/dist.py", line 268, in __init__
      File "build/bdist.macosx-10.10-intel/egg/setuptools/dist.py", line 313, in fetch_build_eggs
      File "build/bdist.macosx-10.10-intel/egg/pkg_resources/__init__.py", line 836, in resolve
      File "build/bdist.macosx-10.10-intel/egg/pkg_resources/__init__.py", line 1081, in best_match
      File "build/bdist.macosx-10.10-intel/egg/pkg_resources/__init__.py", line 1093, in obtain
      File "build/bdist.macosx-10.10-intel/egg/setuptools/dist.py", line 380, in fetch_build_egg
      File "build/bdist.macosx-10.10-intel/egg/setuptools/command/easy_install.py", line 629, in easy_install

      File "build/bdist.macosx-10.10-intel/egg/setuptools/command/easy_install.py", line 659, in install_item

      File "build/bdist.macosx-10.10-intel/egg/setuptools/command/easy_install.py", line 842, in install_eggs

      File "build/bdist.macosx-10.10-intel/egg/setuptools/command/easy_install.py", line 1070, in build_and_install

      File "build/bdist.macosx-10.10-intel/egg/setuptools/command/easy_install.py", line 1058, in run_setup

    distutils.errors.DistutilsError: Setup script exited with error: command 'cc' failed with exit status 1

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/tmp/pip-build-wOHXdq/netlib

Updated after first response for libffi:

After Installing libffi, it started breaking on libxml. I found the lxml on pip. and its break again and looking for libxml :(

104:~ user2368563$ brew install libxml
Error: No available formula for libxml 
Searching formulae...
libxml++    libxml2 libxmlsec1
Searching taps...
homebrew/versions/libxml278
104:~ user2368563$ brew install libxml2
Warning: libxml2-2.9.2 already installed

104:bin user2368563$ sudo pip install lxml
The directory '/Users/alokchoudhary/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/alokchoudhary/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.
Collecting lxml
/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
  Downloading lxml-3.4.4.tar.gz (3.5MB)
    100% |████████████████████████████████| 3.5MB 116kB/s 
Installing collected packages: lxml
  Running setup.py install for lxml
    Complete output from command /usr/bin/python -c "import setuptools, tokenize;__file__='/private/tmp/pip-build-bDtXaT/lxml/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-gmvCN9-record/install-record.txt --single-version-externally-managed --compile:
    /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url'
      warnings.warn(msg)
    Building lxml version 3.4.4.
    Building without Cython.
    Using build configuration of libxslt 1.1.28
    running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.10-intel-2.7
    creating build/lib.macosx-10.10-intel-2.7/lxml
    copying src/lxml/__init__.py -> build/lib.macosx-10.10-intel-2.7/lxml
    copying src/lxml/_elementpath.py -> build/lib.macosx-10.10-intel-2.7/lxml
    copying src/lxml/builder.py -> build/lib.macosx-10.10-intel-2.7/lxml
    copying src/lxml/cssselect.py -> build/lib.macosx-10.10-intel-2.7/lxml
    copying src/lxml/doctestcompare.py -> build/lib.macosx-10.10-intel-2.7/lxml
    copying src/lxml/ElementInclude.py -> build/lib.macosx-10.10-intel-2.7/lxml
    copying src/lxml/pyclasslookup.py -> build/lib.macosx-10.10-intel-2.7/lxml
    copying src/lxml/sax.py -> build/lib.macosx-10.10-intel-2.7/lxml
    copying src/lxml/usedoctest.py -> build/lib.macosx-10.10-intel-2.7/lxml
    creating build/lib.macosx-10.10-intel-2.7/lxml/includes
    copying src/lxml/includes/__init__.py -> build/lib.macosx-10.10-intel-2.7/lxml/includes
    creating build/lib.macosx-10.10-intel-2.7/lxml/html
    copying src/lxml/html/__init__.py -> build/lib.macosx-10.10-intel-2.7/lxml/html
    copying src/lxml/html/_diffcommand.py -> build/lib.macosx-10.10-intel-2.7/lxml/html
    copying src/lxml/html/_html5builder.py -> build/lib.macosx-10.10-intel-2.7/lxml/html
    copying src/lxml/html/_setmixin.py -> build/lib.macosx-10.10-intel-2.7/lxml/html
    copying src/lxml/html/builder.py -> build/lib.macosx-10.10-intel-2.7/lxml/html
    copying src/lxml/html/clean.py -> build/lib.macosx-10.10-intel-2.7/lxml/html
    copying src/lxml/html/defs.py -> build/lib.macosx-10.10-intel-2.7/lxml/html
    copying src/lxml/html/diff.py -> build/lib.macosx-10.10-intel-2.7/lxml/html
    copying src/lxml/html/ElementSoup.py -> build/lib.macosx-10.10-intel-2.7/lxml/html
    copying src/lxml/html/formfill.py -> build/lib.macosx-10.10-intel-2.7/lxml/html
    copying src/lxml/html/html5parser.py -> build/lib.macosx-10.10-intel-2.7/lxml/html
    copying src/lxml/html/soupparser.py -> build/lib.macosx-10.10-intel-2.7/lxml/html
    copying src/lxml/html/usedoctest.py -> build/lib.macosx-10.10-intel-2.7/lxml/html
    creating build/lib.macosx-10.10-intel-2.7/lxml/isoschematron
    copying src/lxml/isoschematron/__init__.py -> build/lib.macosx-10.10-intel-2.7/lxml/isoschematron
    copying src/lxml/lxml.etree.h -> build/lib.macosx-10.10-intel-2.7/lxml
    copying src/lxml/lxml.etree_api.h -> build/lib.macosx-10.10-intel-2.7/lxml
    copying src/lxml/includes/c14n.pxd -> build/lib.macosx-10.10-intel-2.7/lxml/includes
    copying src/lxml/includes/config.pxd -> build/lib.macosx-10.10-intel-2.7/lxml/includes
    copying src/lxml/includes/dtdvalid.pxd -> build/lib.macosx-10.10-intel-2.7/lxml/includes
    copying src/lxml/includes/etreepublic.pxd -> build/lib.macosx-10.10-intel-2.7/lxml/includes
    copying src/lxml/includes/htmlparser.pxd -> build/lib.macosx-10.10-intel-2.7/lxml/includes
    copying src/lxml/includes/relaxng.pxd -> build/lib.macosx-10.10-intel-2.7/lxml/includes
    copying src/lxml/includes/schematron.pxd -> build/lib.macosx-10.10-intel-2.7/lxml/includes
    copying src/lxml/includes/tree.pxd -> build/lib.macosx-10.10-intel-2.7/lxml/includes
    copying src/lxml/includes/uri.pxd -> build/lib.macosx-10.10-intel-2.7/lxml/includes
    copying src/lxml/includes/xinclude.pxd -> build/lib.macosx-10.10-intel-2.7/lxml/includes
    copying src/lxml/includes/xmlerror.pxd -> build/lib.macosx-10.10-intel-2.7/lxml/includes
    copying src/lxml/includes/xmlparser.pxd -> build/lib.macosx-10.10-intel-2.7/lxml/includes
    copying src/lxml/includes/xmlschema.pxd -> build/lib.macosx-10.10-intel-2.7/lxml/includes
    copying src/lxml/includes/xpath.pxd -> build/lib.macosx-10.10-intel-2.7/lxml/includes
    copying src/lxml/includes/xslt.pxd -> build/lib.macosx-10.10-intel-2.7/lxml/includes
    copying src/lxml/includes/etree_defs.h -> build/lib.macosx-10.10-intel-2.7/lxml/includes
    copying src/lxml/includes/lxml-version.h -> build/lib.macosx-10.10-intel-2.7/lxml/includes
    creating build/lib.macosx-10.10-intel-2.7/lxml/isoschematron/resources
    creating build/lib.macosx-10.10-intel-2.7/lxml/isoschematron/resources/rng
    copying src/lxml/isoschematron/resources/rng/iso-schematron.rng -> build/lib.macosx-10.10-intel-2.7/lxml/isoschematron/resources/rng
    creating build/lib.macosx-10.10-intel-2.7/lxml/isoschematron/resources/xsl
    copying src/lxml/isoschematron/resources/xsl/RNG2Schtrn.xsl -> build/lib.macosx-10.10-intel-2.7/lxml/isoschematron/resources/xsl
    copying src/lxml/isoschematron/resources/xsl/XSD2Schtrn.xsl -> build/lib.macosx-10.10-intel-2.7/lxml/isoschematron/resources/xsl
    creating build/lib.macosx-10.10-intel-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
    copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_abstract_expand.xsl -> build/lib.macosx-10.10-intel-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
    copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_dsdl_include.xsl -> build/lib.macosx-10.10-intel-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
    copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_schematron_message.xsl -> build/lib.macosx-10.10-intel-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
    copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_schematron_skeleton_for_xslt1.xsl -> build/lib.macosx-10.10-intel-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
    copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_svrl_for_xslt1.xsl -> build/lib.macosx-10.10-intel-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
    copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/readme.txt -> build/lib.macosx-10.10-intel-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
    running build_ext
    building 'lxml.etree' extension
    creating build/temp.macosx-10.10-intel-2.7
    creating build/temp.macosx-10.10-intel-2.7/src
    creating build/temp.macosx-10.10-intel-2.7/src/lxml
    cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -arch i386 -pipe -I/usr/include/libxml2 -I/private/tmp/pip-build-bDtXaT/lxml/src/lxml/includes -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/lxml/lxml.etree.c -o build/temp.macosx-10.10-intel-2.7/src/lxml/lxml.etree.o -w -flat_namespace
    In file included from src/lxml/lxml.etree.c:239:
    /private/tmp/pip-build-bDtXaT/lxml/src/lxml/includes/etree_defs.h:14:10: fatal error: 'libxml/xmlversion.h' file not found
    #include "libxml/xmlversion.h"
             ^
    1 error generated.
    error: command 'cc' failed with exit status 1

    ----------------------------------------
Command "/usr/bin/python -c "import setuptools, tokenize;__file__='/private/tmp/pip-build-bDtXaT/lxml/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-gmvCN9-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/tmp/pip-build-bDtXaT/lxml
Community
  • 1
  • 1
Alok C
  • 2,787
  • 3
  • 25
  • 44

1 Answers1

0

If you read through your log carefully you might spot this line:

c/_cffi_backend.c:13:10: fatal error: 'ffi.h' file not found

The "fatal error" part is especially important. :)

This means that the ffi headers couldn't be located by your compiler. I'm not sure how to do it since I'm not a Mac user but maybe homebrew could help you, or Google. To me it seems like you should install homebrew and then just run:

brew install libffi

Then try pip again.

Edit

The full list of dependencies are:

  • python
  • libffi
  • libssl
  • libxml2
  • libxslt1

So you'll need all those, and their headers, if you want to continue down this path.

An easier solution is to download pre-built binaries for your Mac, from mitmproxy.org (OSX Mountain Lion and later). I found this info in the installation docs.

André Laszlo
  • 15,169
  • 3
  • 63
  • 81
  • I did install libffi, now its breaking on lxml. I did find lxml installed that but still its breaking. please see updated. – Alok C Jul 14 '15 at 18:24