python installation import under the reptile -Ubuntu18.04 environment, selenium, chrome, chromedriver

First day of school holiday reptiles myself.
Linux (ubuntu18.04):
First, install the python
in the python Ubuntu18.04 is automatically installed. Figure:
Here Insert Picture DescriptionSecond, install python-requests library
action requests library What is it? His role is to simulate the browser sends a request to the server.
Ibid requests library also comes with. But we have seen a situation in which the use of requests, as follows:

gxa@gxa-virtual-machine:~$ python3
Python 3.6.8 (default, Jan 14 2019, 11:02:34) 
[GCC 8.0.1 20180414 (experimental) [trunk revision 259383]] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
/usr/lib/python3/dist-packages/requests/__init__.py:80: RequestsDependencyWarning: urllib3 (1.25.3) or chardet (3.0.4) doesn't match a supported version!
  RequestsDependencyWarning)

What does that mean?
That is to say: python library urllib3 (1.24.1) or chardet (3.0.4 ) version is not compatible. So we execute the following command:

~$pip uninstall urllib3
~$pip uninstall chardet

It appears below we can see that the installation was successful:

gxa@gxa-virtual-machine:~$ pip3 uninstall urllib3
Uninstalling urllib3-1.25.3:
  /home/gxa/.local/lib/python3.6/site-packages/urllib3-1.25.3.dist-info/INSTALLER
  /home/gxa/.local/lib/python3.6/site-packages/urllib3-1.25.3.dist-info/LICENSE.txt
  /home/gxa/.local/lib/python3.6/site-packages/urllib3-1.25.3.dist-info/METADATA
  /home/gxa/.local/lib/python3.6/site-packages/urllib3-1.25.3.dist-info/RECORD
  /home/gxa/.local/lib/python3.6/site-packages/urllib3-1.25.3.dist-info/WHEEL
  /home/gxa/.local/lib/python3.6/site-packages/urllib3-1.25.3.dist-info/top_level.txt
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/__init__.py
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/__pycache__/__init__.cpython-36.pyc
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/__pycache__/_collections.cpython-36.pyc
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/__pycache__/connection.cpython-36.pyc
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/__pycache__/connectionpool.cpython-36.pyc
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/__pycache__/exceptions.cpython-36.pyc
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/__pycache__/fields.cpython-36.pyc
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/__pycache__/filepost.cpython-36.pyc
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/__pycache__/poolmanager.cpython-36.pyc
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/__pycache__/request.cpython-36.pyc
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/__pycache__/response.cpython-36.pyc
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/_collections.py
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/connection.py
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/connectionpool.py
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/contrib/__init__.py
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/contrib/__pycache__/__init__.cpython-36.pyc
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/contrib/__pycache__/_appengine_environ.cpython-36.pyc
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/contrib/__pycache__/appengine.cpython-36.pyc
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/contrib/__pycache__/ntlmpool.cpython-36.pyc
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/contrib/__pycache__/pyopenssl.cpython-36.pyc
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/contrib/__pycache__/securetransport.cpython-36.pyc
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/contrib/__pycache__/socks.cpython-36.pyc
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/contrib/_appengine_environ.py
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/contrib/_securetransport/__init__.py
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/contrib/_securetransport/__pycache__/__init__.cpython-36.pyc
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/contrib/_securetransport/__pycache__/bindings.cpython-36.pyc
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/contrib/_securetransport/__pycache__/low_level.cpython-36.pyc
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/contrib/_securetransport/bindings.py
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/contrib/_securetransport/low_level.py
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/contrib/appengine.py
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/contrib/ntlmpool.py
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/contrib/pyopenssl.py
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/contrib/securetransport.py
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/contrib/socks.py
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/exceptions.py
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/fields.py
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/filepost.py
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/packages/__init__.py
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/packages/__pycache__/__init__.cpython-36.pyc
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/packages/__pycache__/six.cpython-36.pyc
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/packages/backports/__init__.py
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/packages/backports/__pycache__/__init__.cpython-36.pyc
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/packages/backports/__pycache__/makefile.cpython-36.pyc
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/packages/backports/makefile.py
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/packages/rfc3986/__init__.py
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/packages/rfc3986/__pycache__/__init__.cpython-36.pyc
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/packages/rfc3986/__pycache__/_mixin.cpython-36.pyc
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/packages/rfc3986/__pycache__/abnf_regexp.cpython-36.pyc
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/packages/rfc3986/__pycache__/api.cpython-36.pyc
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/packages/rfc3986/__pycache__/builder.cpython-36.pyc
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/packages/rfc3986/__pycache__/compat.cpython-36.pyc
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/packages/rfc3986/__pycache__/exceptions.cpython-36.pyc
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/packages/rfc3986/__pycache__/iri.cpython-36.pyc
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/packages/rfc3986/__pycache__/misc.cpython-36.pyc
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/packages/rfc3986/__pycache__/normalizers.cpython-36.pyc
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/packages/rfc3986/__pycache__/parseresult.cpython-36.pyc
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/packages/rfc3986/__pycache__/uri.cpython-36.pyc
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/packages/rfc3986/__pycache__/validators.cpython-36.pyc
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/packages/rfc3986/_mixin.py
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/packages/rfc3986/abnf_regexp.py
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/packages/rfc3986/api.py
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/packages/rfc3986/builder.py
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/packages/rfc3986/compat.py
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/packages/rfc3986/exceptions.py
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/packages/rfc3986/iri.py
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/packages/rfc3986/misc.py
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/packages/rfc3986/normalizers.py
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/packages/rfc3986/parseresult.py
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/packages/rfc3986/uri.py
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/packages/rfc3986/validators.py
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/packages/six.py
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/packages/ssl_match_hostname/__init__.py
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/packages/ssl_match_hostname/__pycache__/__init__.cpython-36.pyc
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/packages/ssl_match_hostname/__pycache__/_implementation.cpython-36.pyc
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/packages/ssl_match_hostname/_implementation.py
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/poolmanager.py
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/request.py
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/response.py
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/util/__init__.py
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/util/__pycache__/__init__.cpython-36.pyc
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/util/__pycache__/connection.cpython-36.pyc
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/util/__pycache__/queue.cpython-36.pyc
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/util/__pycache__/request.cpython-36.pyc
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/util/__pycache__/response.cpython-36.pyc
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/util/__pycache__/retry.cpython-36.pyc
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/util/__pycache__/ssl_.cpython-36.pyc
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/util/__pycache__/timeout.cpython-36.pyc
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/util/__pycache__/url.cpython-36.pyc
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/util/__pycache__/wait.cpython-36.pyc
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/util/connection.py
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/util/queue.py
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/util/request.py
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/util/response.py
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/util/retry.py
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/util/ssl_.py
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/util/timeout.py
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/util/url.py
  /home/gxa/.local/lib/python3.6/site-packages/urllib3/util/wait.py
Proceed (y/n)? y
  Successfully uninstalled urllib3-1.25.3 //这是重点奥。

If there are no requests the library, we can use the following command:

pip install requests

About pip this command, we introduce the following later.
Third, then we install selenium library friends.
What is the role of the library is it? He is an automated testing tool that we can use it drive the browser perform specific actions, such as clicking, pull down other operations. Similarly, we install the library, also you need to use the following command:

pip3 install selenium

But then we discovered and can not perform, we need to install this command in Ubuntu at the time of executing the command, but we are in the process of installation, and can not find the installation was successful. Why is there such a problem?
The reason is simply that comes with the source is not found python3-pip this package, so we must first add the following sources:
* How to solve pip3 install unsuccessful? ** course it is for the source.

# 打开源配置文件
sudo vim /etc/apt/sources.list  //这里要注意我们在退出保存的时候使用的命令是: :wq 而不是 :qw
 
 
# 在原有基础上添加以下的源
deb http://cn.archive.ubuntu.com/ubuntu bionic main multiverse restricted universe
deb http://cn.archive.ubuntu.com/ubuntu bionic-updates main multiverse restricted universe
deb http://cn.archive.ubuntu.com/ubuntu bionic-security main multiverse restricted universe
deb http://cn.archive.ubuntu.com/ubuntu bionic-proposed main multiverse restricted universe
 
 
# 更新一下源
sudo apt update

As shown (the first four that we add the source):
Here Insert Picture DescriptionAfter the installation is complete we see the following versions:

gxa@gxa-virtual-machine:~$ pip3 --version
pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)

We then execute the following command to install selenium library:
or execute (sudo apt install python3-pip)
Here Insert Picture Descriptionafter the completion of the above steps, we execute the following command Austria:
Here Insert Picture Descriptionsee two libraries have installed it successfully.
We have previously said that the role of selenium in the end anyway, so this course is to tie the library browser ah. On how to install goole-chrome in the ubuntu?
Fourth, then we install chromedriver
First we open goole-chrome view the version number, and then download the corresponding version chromedriver official website.
Here Insert Picture DescriptionWe can see the version number is 75.0.3440.100. Then we in the official website to download the appropriate version. After the download is complete we: Move the file to the / usr / bin directory, but bloggers while on the move appeared the following:
Here Insert Picture Description? Why file has not moved successfully do it is because of our virtual machines simply do not / home / gax / Desktop / chromedriver Zhe Ergen file directory. So I changed the following moves. cd Desktop file is moved.
Here Insert Picture DescriptionThe final document was successfully moved.
We enter the command: chromedrier start.
Here Insert Picture Descriptionok friends.

Guess you like

Origin blog.csdn.net/weixin_43803070/article/details/94346067