部署一个Python爬虫环境(四)-ubuntu版_Server系统过渡篇

一,部署环境及安装包

系统:Ubuntu 18.04.5 LTS

1.系统自带的python或python3.7

2.Python安装 包安装和管理工具pip

3.pip安装 代理/抓包工具Mitmproxy

4.pip安装 传输和存储数据工具protobuf

二,操作:

查看软件版本

root@root1:~# python3 --version
Python 3.6.9


root@root1:~# pip --version

Command 'pip' not found, but can be installed with:apt install python-pip

 

root@root1:~# mitmproxy --version

Command 'mitmproxy' not found, but can be installed with:apt install mitmproxy

1.Python3.6.9版(先用这一版,不行在用3.7)

1)安装pip

su root  #切换到root用户

sudo apt update

sudo apt install python3-pip

  结果:

root@root1:~# pip3 --version
pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)

2)安装Mitmproxy

pip3 install mitmproxy
#执行完显示的内容:

Successfully installed Brotli-1.0.9 Jinja2-2.11.3 Werkzeug-1.0.1 asgiref-3.3.1 certifi-2020.12.5 cffi-1.14.4 click-7.1.2 cryptography-3.2.1 dataclasses-0.8 flask-1.1.2 h11-0.12.0 h2-4.0.0 hpack-4.0.0 hyperframe-6.0.0 itsdangerous-1.1.0 kaitaistruct-0.9 ldap3-2.8.1 mitmproxy-5.3.0 msgpack-1.0.2 passlib-1.7.4 protobuf-3.13.0 publicsuffix2-2.20191221 pyOpenSSL-19.1.0 pycparser-2.20 pyparsing-2.4.7 pyperclip-1.8.1 ruamel.yaml-0.16.12 ruamel.yaml.clib-0.2.2 sortedcontainers-2.2.2 tornado-6.1 urwid-2.1.2 wsproto-0.15.0 zstandard-0.14.1

  结果:

root@root1:~# mitmproxy --version
Mitmproxy: 5.3.0
Python:    3.6.9
OpenSSL:   OpenSSL 1.1.1h  22 Sep 2020
Platform:  Linux-4.15.0-135-generic-x86_64-with-Ubuntu-18.04-bionic

3)安装protobuf

root@root1:~# pip3 install pyprotobuf
Collecting pyprotobuf
  Downloading https://files.pythonhosted.org/packages/df/c9/cb3d6f51bf724da92a96d93ddf5591a12ecca1ab09d0a75d4ac8c88e63af/pyprotobuf-0.8.tar.gz (48kB)
    100% |████████████████████████████████| 51kB 141kB/s
Building wheels for collected packages: pyprotobuf
  Running setup.py bdist_wheel for pyprotobuf ... done
  Stored in directory: /root/.cache/pip/wheels/74/3c/39/529a6823a714fb32f99ef95765aaa6463199d55a02b098e191
Successfully built pyprotobuf
Installing collected packages: pyprotobuf
Successfully installed pyprotobuf-0.8

  查看结果(python环境里使用 'import google.protobuf'):

root@root1:~# python3
Python 3.6.9 (default, Oct  8 2020, 12:12:24)
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import google.protobuf
>>>

  结果如上图说明成功。退出为 exit();

补充:

  版本统计:

    Ubuntu 18.04.5 LTS;

    Python 3.6.9;

    pip 9.0.1;

    Mitmproxy 5.3.0;

    pyprotobuf 0.8;

2.Python3.7版

  省略

365个夜晚,我希望做到两天更一篇博客。加油,小白!
原文地址:https://www.cnblogs.com/qq2806933146xiaobai/p/14372525.html