通过pip安装mitmproxy时遇到问题

时间:2015-07-14 15:19:19

标签: python pip

通过pip安装mitmproxy时遇到以下问题。 我尝试过与蛋错误相关的其他修复。这里堆栈溢出。 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

首次回复libffi后更新:

安装libffi后,它开始破解libxml。我在点子上发现了lxml。 并再次打破并寻找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

1 个答案:

答案 0 :(得分:0)

如果仔细阅读日志,可能会发现这一行:

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

“致命错误”部分尤为重要。 :)

这意味着编译器无法找到ffi标头。我不知道怎么做,因为我不是Mac用户,但也许自制软件可以帮助你,或Google。对我来说,似乎你应该安装homebrew,然后运行:

brew install libffi

然后再试一次。

修改

依赖项的完整列表是:

  • libffi
  • 的libssl
  • 的libxml2
  • libxslt1

因此,如果您想继续沿着这条路走下去,那么您将需要所有这些及其标题。

更简单的解决方案是从mitmproxy.org(OSX Mountain Lion及更高版本)为您的Mac下载预构建的二进制文件。我在installation docs

中找到了此信息