概述
Windows下python安装easy_install和pip并安装requests和BeautifulSoup
当我们使用Python爬取网页内容的时候往往需要用到requests和BeautifulSoup两个库
一、安装easy_instal和pip
2、将get-pip.py 放在Python根目录下,我的是C:/Python27/
3、打开cmd
4、输入cd C:Python27
5、输入get-pip.py
但Python安装pip一直报错
解决办法:
1、在Python的安装目录C:/Python27/Lib/里找到mimetypes.py文件
2、打开mimetypes.py文件,在import结束后添加以下代码:
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
3、再次打开cmd
4、运行cd C:Python27
5、输入get-pip.py
最后在Python根目录下新添了Scripts文件夹:
easy_install和pip已经安装成功:
安装成功后,记得将mimetypes.py改回来,不然会导致Python编译代码出错
另外,如果需要安装其他库,报错的话再修改mimetypes.py文件,如此反复
二、安装requests库(前提是完成了easy_install和pip的安装)
1、运行cmd
2、cd C:Python27Scripts
3、直接使用:easy_install requests或者pip install requests来安装。
卸载:使用pip uninstallrequests
三、安装BeautifulSoup(前提是完成了easy_install和pip的安装)
1、运行cmd
2、cd C:Python27Scripts
3、直接使用:easy_install BeautifulSoup或者pip install BeautifulSoup来安装。
卸载:使用pip uninstall BeautifulSoup
最后
以上就是现实皮皮虾为你收集整理的python beautifulsoup库安装_Windows下python安装easy_install和pip&安装requests和BeautifulSoup库...的全部内容,希望文章能够帮你解决python beautifulsoup库安装_Windows下python安装easy_install和pip&安装requests和BeautifulSoup库...所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复