windows使用pip安装selenium报错问题

UnicodeDecodeError: 'ascii' codec can't decode byte 0xb9 in position 7: ordinal not in range(128)

这是编码问题,需要在你的python安装目录下

这是我的安装目录C:Python27Libsite-packages

添加sitecustomize.py文件

文件内容添加

import sys
sys.setdefaultencoding('gb2312')

之后在执行pip install -U selenium安装就不会报错啦

sys.setdefaultencoding是python设置系统默认编码,python会在下次自动运行这个文件sitecustomize.py

原文地址:https://www.cnblogs.com/JahanGu/p/8337813.html