Python + Selenium Environment Construction
Note: This article is based on on-line data collection and verification, only for learning
Prepare as follows:
1. Download python
http://python.org/getit/
2. Download Setuptools
Http://pypi.python.org/pypi/setuptools
3. Download pip
Https://pypi.python.org/pypi/pip
Setuptools is a Python-based package tool that can help us easily download, build, install, upgrade, and uninstall Python packages.
Pip is a Python software package installation and management tool, with this tool, we only need a command to be able to easily python any class library.
Windows Environment Installation
1. Install Python
Install the Python Development environment package, select the installation path to install, I choose Python 2.x, the installation directory is: C:\Python27.
Configuring Environment variables
Desktop My Computer Right-click Menu--Properties--advanced--environment variables--the Path in the system variable is:
Variable name: PATH
Variable value:; C:\PYTHON27 (cursor moves to the end, copy and paste in)
2. Installing Setuptools
setuptools-1.3.2.tar.gz file (may not be the same version), unzip the file, enter the DOS command Prompt window (start-run--cmd command, enter) to execute setup.py:
C:\setuptools-1.3>python setup.py Install
Configure environment variables (optional)
Add environment variables:; C:\Python27\Scripts
3. install PIP
Install PIP, download pip-1.4.1.tar.gz via the link provided above (the version may not be the same), I unzipped in the C:\pip-1.4.1 directory;
Open a command prompt (start-run--cmd command, enter) into the C:\pip-1.4.1 directory to enter:
C:\pip-1.4.1 > Python setup.py install
Then switch to the C:\Python27\Scripts directory to enter:
C:\Python27\Scripts > Easy_install pip
4. Installing Selenium
Networked installation
If the computer is connected, you can enter the command installation directly under C:\Python27\Scripts:
C:\Python27\Scripts > Pip install-u Selenium
Offline Installation
If you do not have a network, you can install it by downloading:
Selenium:https://pypi.python.org/pypi/selenium
and unzip the entire directory into the C:\Python27\Lib\site-packages directory, open a DOS command Prompt window, enter the C:\Python27\Lib\site-packages\selenium-2.46.0 directory:
C:\Python27\Lib\site-packages\selenium-2.46.0 > Python setup.py install
Verify that the selenium is installed successfully:
Enter Python IDLE, entered in the Python shell: from selenium import Webdriver
If you do not make an error, success
Linux Environment Installation (excerpt from Internet, not verified)
The following is an example of Unbuntu installation, other versions of Linux may be different, in the vast majority of Linux and UNIX system installation (including Mac OS X), Python interpreter already exists. All we need to do is open the terminal and enter the Python command to verify that the Python installation is no longer described here.
1 , Installation: Setuptools
[Email protected]:~# apt-get Install Python-setuptools
2 , install Pip
Download the PIP installation file, switch to the file directory, unzip it:
[Email protected]:/home/user/python# tar-zxvf pip-1.4.1.tar.gz
Switch to unzip directory:
[Email protected]:/home/user/python# cd PIP-1.4.1/
To install the PIP:
[Email protected]:/home/user/python/pip-1.4.1# python setup.py Install
3 , installation Selenium
[Email protected]:/home/user/python/pip-1.4.1# pip Install-u Selenium
Python + Selenium Environment Building