python环境搭建
1. Open the python official website ( https://www.python.org/ )
2. Download python
Method 1: Click to download the latest version directly as shown in the figure
Method 2: Download the corresponding version Click on windows as shown in the figure:
Or click the corresponding version to download:
3. Install the program after the download
is complete: 1. Find the installation file for download:
2. Click to install
## According to the user's own decision (the blogger has not disabled it)
4. After the installation is complete, check whether the system environment variable is added
(the latest version of win10 The property page that may be opened is different)
new version
old version
// If you do not click to automatically add to the system environment variable during the installation process, the user can add it manually
5. Start CMD (win (referring to the win key with an icon on the keyboard) + r)
1. After entering cmd, it will enter the command prompt window interface
2. Enter python
3. Enter exit() to exit
4. Enter pip or pip list
5. If you don’t know what directory python is installed in, you can use the command to find it or check it according to the environment variables of the system.
6. The above are the steps to install the python environment.
selenium环境安装
Note: Please complete the python installation when installing the selenium environment.
1. Open the cmd command prompt window
and enter pip install selenium to install the latest version directly
Note: pip install selenium==version number, you can download the corresponding version of selenium.
View version: Enter a random version number to display all versions. As shown in the figure
2. Install with version 3.141.0
// The following picture appears, which may be due to the network.
The following installation is complete
3. After the installation is successful, enter python, enter the shell mode, enter from selenium import webdriver, no error means that selenium is installed success.
4. You can also enter pip show selenium to view the installed selenium version.
Uninstall: pip uninstall selenium
Install or upgrade: pip install -U selenium
5. Enter the following code and run it (the blogger runs it under the pycharm editor) and
the result as shown in the figure will appear
from selenium import webdriver
from time import sleep
driver = webdriver.Firefox()
driver.get('http://www.baidu.com')
sleep(3)
driver.quit()
Solution:
browser driver installation
Firefox installation driver
download address ( https://github.com/mozilla/geckodriver/releases/ )
1. Download by yourself according to the system version (the blogger’s browser and driver take the latest download as an example)
2 . After the download is complete, extract it to the root directory of python:
Chrome installation driver
download address ( http://npm.taobao.org/mirrors/chromedriver/ )
1. Select the corresponding version (browser 64 can download 32-bit backward compatible)
3. Unzip the downloaded driver and put it in the python root directory:
re-run the code just now to successfully open the browser and run: