lanying56123 发表于 2015-5-16 05:49:11

win7、linux安装使用pip、mitmproxy

  安装pip https://pip.pypa.io/en/latest/installing.html
  步骤:
  下载 https://bootstrap.pypa.io/get-pip.py



python get-pip.py


D:\pip>python get-pip.py
Collecting pip
Downloading pip-6.0.6-py2.py3-none-any.whl (1.3MB)
100% |################################| 1.3MB 74kB/s ta 0:00:011
Collecting setuptools
Downloading setuptools-12.0.4-py2.py3-none-any.whl (502kB)
100% |################################| 503kB 117kB/s ta 0:00:01
Installing collected packages: setuptools, pip

Successfully installed pip-6.0.6 setuptools-12.0.4


python -m pip


Usage:
D:\Python27\python.exe -m pip
Commands:
install                     Install packages.
uninstall                   Uninstall packages.
freeze                      Output installed packages in requirements format.
list                        List installed packages.
show                        Show information about installed packages.
search                      Search PyPI for packages.
wheel                     Build wheels from your requirements.
zip                         DEPRECATED. Zip individual packages.
unzip                     DEPRECATED. Unzip individual packages.
help                        Show help for commands.
General Options:
-h, --help                  Show help.
--isolated                  Run pip in an isolated mode, ignoring
environment variables and user configuration.
-v, --verbose               Give more output. Option is additive, and can be
used up to 3 times.
-V, --version               Show version and exit.
-q, --quiet               Give less output.
--log               Path to a verbose appending log.
--proxy            Specify a proxy in the form
proxy.server:port.
--retries          Maximum number of retries each connection should
attempt (default 5 times).
--timeout            Set the socket timeout (default 15 seconds).
--exists-action   Default action when a path already exists:
(s)witch, (i)gnore, (w)ipe, (b)ackup.
--trusted-host    Mark this host as trusted, even though it does
not have valid or any HTTPS.
--cert                Path to alternate CA bundle.
--client-cert         Path to SSL client certificate, a single file
containing the private key and the certificate
in PEM format.
--cache-dir            Store the cache data in .
--no-cache-dir            Disable the cache.
--disable-pip-version-check
Don't periodically check PyPI to determine
whether a new version of pip is available for
download. Implied with --no-index.
  安装依赖包



python -m pip install netlib pyopenssl pyasn1 urwid pil lxml flask
  错误:
  File "D:\Python27\lib\mimetypes.py", line 249, in enum_types
      ctype = ctype.encode(default_encoding) # omit in 3.x!
UnicodeDecodeError: 'ascii' codec can't decode byte 0xb0 in position 1: ordinal not in range(128)
  解决方案:
  打开D:\Python27\lib\mimetypes.py文件,在256行,将



default_encoding = sys.getdefaultencoding()
  改为



      if sys.getdefaultencoding() != 'gbk':
reload(sys)
sys.setdefaultencoding('gbk')
default_encoding = sys.getdefaultencoding()
  由于pil安装出错,所以先:



python -m pip install netlib pyopenssl pyasn1 urwid lxml flask
  然后:



python -m pip install pyamf protobuf
  又出错:
  error: Microsoft Visual C++ 9.0 is required (Unable to find vcvarsall.bat).
Get it from http://aka.ms/vcpython27
  需要装 Microsoft Visual C++ Compiler for Python 2.7(共 83.8 MB)
  http://www.microsoft.com/en-us/download/confirmation.aspx?id=44266
  再试:



python -m pip install pyamf protobuf
  下一步:



python -m pip install pil --allow-external PIL --allow-unverified PIL
  下一步:



python -m pip install nose pathod countershape
  最后:



python -m pip install mitmproxy
  
  参考资料:
  https://pip.pypa.io/en/latest/installing.html
http://m.blog.iyunv.com/blog/roler_/40398789
http://netsecurity.iyunv.com/art/201311/416548.htm
http://www.ajucs.com/archives/565.html

  ——————————————————————————————————
  Linux:
  类似windows就是pip命令不用加前面的python -m ,如果不是管理员需要sudo。
  在pip install netlib pyopenssl pyasn1 urwid lxml flask的时候遇到的错误:

  src/lxml/lxml.etree.c:8:22: 错误:pyconfig.h:没有那个文件或目录





yum install python-devel
  c/_cffi_backend.c:13:17: 错误:ffi.h:没有那个文件或目录




yum install libffi-devel
  其他的还有:



yum install gcc
yum install libxml2
yum install libxslt-devel libxml2-devel
  然后:



pip install pil --allow-external PIL --allow-unverified PIL
pip install pyamf protobuf
pip install nose pathod countershape
pip install mitmproxy
  “pip install mitmproxy”遇到错误:

  # pip install mitmproxy
Collecting mitmproxy
Using cached mitmproxy-0.11.3.tar.gz
    Traceback (most recent call last):
      File "", line 20, in
页: [1]
查看完整版本: win7、linux安装使用pip、mitmproxy