Windows64+Python3+selenium3自动化环境的搭建(1)

一、Python安装
1、Python3官网下载
https://www.python.org/downlo…

2、选择对应系统和版本(注意是32位还是64位,我使用的是windows64位)

《Windows64+Python3+selenium3自动化环境的搭建(1)》

3、如果下载后双击出现提示:安装失败(Setup failed)(若无出现下方界面则跳过这一步)

《Windows64+Python3+selenium3自动化环境的搭建(1)》

意思是:缺失了Service Pack 1
解决方案可到对应官网下载https://www.microsoft.com/zh-…

4、跳转到对应官网后点击下载按钮

《Windows64+Python3+selenium3自动化环境的搭建(1)》

点击后会跳转到下方界面,滚动条滑到底部(先查看你的操作系统是32位还是64位)

Windows6.1-KB976932-X86.exe -此程序可将Sp1安装到运行Windows7的32位计算机上。
Windows6.1-KB976932-X64.exe -此程序可将Sp1安装到运行Windows7或Windows Server 2008 R2 的64位计算机上。

注意:安装过程可能需要一个小时左右,安装成功后会提示重启电脑,先保存你需要文档。

5、成功安装后,再次双击python的exe文件就会出现下方界面。

《Windows64+Python3+selenium3自动化环境的搭建(1)》

先勾选底部添加路径,再点击Install Now,成功后弹出下方界面

《Windows64+Python3+selenium3自动化环境的搭建(1)》

6、操作完上一步并不代表就可以成功使用python3,需要在cmd命令窗口中输入python/python -V查看是否成功安装。
(若不出现下方界面则跳过此步)

《Windows64+Python3+selenium3自动化环境的搭建(1)》

启动python3.6后,错误提示api-ms-win-crt-runtime-l1-1-0.dll丢失。
处理方法:
下载安装VC运行库即可。
地址:
https://www.microsoft.com/zh-…

《Windows64+Python3+selenium3自动化环境的搭建(1)》

点击下载按钮跳转

《Windows64+Python3+selenium3自动化环境的搭建(1)》

下载成功后双击打开进行安装

《Windows64+Python3+selenium3自动化环境的搭建(1)》

《Windows64+Python3+selenium3自动化环境的搭建(1)》

再次在cmd命令窗口输入python如果还是没有处理成功
解决方案:
删除掉已有的api-ms-win-crt-runtime-l1-1-0.dll,因为VC redit.exe安装完成会重新生成,不同系统存放位置如下【C:WindowsSystem32和C:WindowsSysWOW64检查下】

注意:删除上述内容后要重新双击VC_redit.exe修复运行库,再重启电脑即可。

8、Windows+R调出命令窗口并输入python/python -V,出现下图显示内容则表示python3.6.4版本安装成功。

《Windows64+Python3+selenium3自动化环境的搭建(1)》

出现第六步的原因:api-ms-win-crt-runtime就是MFC的运行时环境的库,python在windows上编译也是用微软的visual studio C++编译的,底层也会用到微软提供的C++库和runtime库,安装Visual C++ Redistributable for Visual Studio 2015 组件即可解决此问题。

二、安装pip
1、下载地址:https://pypi.python.org/pypi/…

《Windows64+Python3+selenium3自动化环境的搭建(1)》

2、下载完成后,解压出一个文件夹,然后用CMD控制台进入解压目录,输入:
python setup.py install

《Windows64+Python3+selenium3自动化环境的搭建(1)》

出现上述报错:大致意思是说缺少setuptools模块,所以要先安装setuptools模块

3、下载setuptools源码地址:https://pypi.python.org/pypi/…

《Windows64+Python3+selenium3自动化环境的搭建(1)》

(1)下载解压后先进入到该文件中;
(2)按住shrift键;
(3)鼠标右键单击在“在此处打开命令窗口(W)

4、在调出的命令窗口中输入:python setup.py install 回车

《Windows64+Python3+selenium3自动化环境的搭建(1)》

出现上述窗口说明安装成功

5、最后新开一个命令窗口,输入easy_install 回车,进行检测。
如果提示:error: No urls, filenames, or requirements specified (see –help)
说明安装成功,它在提示你命令后面需要跟参数。

《Windows64+Python3+selenium3自动化环境的搭建(1)》

6、现在可以直接用easy_install来安装pip

《Windows64+Python3+selenium3自动化环境的搭建(1)》

7、最后安装一些python包,比如Tornado这个Web框架,安装selenium

《Windows64+Python3+selenium3自动化环境的搭建(1)》

在命令窗口输入 pip install selenium

《Windows64+Python3+selenium3自动化环境的搭建(1)》

三、下载安装对应版本的谷歌浏览器(其它)和相应驱动

1、下载驱动版本地址:http://blog.csdn.net/huilan_s…

2、关键步骤:把下载成功的驱动包chromedriver.exe解压出来,放在谷歌浏览器安装目录下的Application目录中(鼠标右键点击谷歌图标,选择属性,可在起始位置查看谷歌目录);

《Windows64+Python3+selenium3自动化环境的搭建(1)》

3、然后配置系统环境变量在path中添加chromedriver.exe的路径。

《Windows64+Python3+selenium3自动化环境的搭建(1)》

4、将chromedriver.exe放在C盘中windows文件夹下的SysWOW64,如果是32位系统则放在System32中

《Windows64+Python3+selenium3自动化环境的搭建(1)》

四、打开IDLE检验环境是否搭建成功

《Windows64+Python3+selenium3自动化环境的搭建(1)》

出现下方界面则表示搭建成功

《Windows64+Python3+selenium3自动化环境的搭建(1)》

    原文作者:缘以微如此
    原文地址: https://segmentfault.com/a/1190000014021333
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞