如何在Windows下,python3.5.1下安装BeautifuSoup。
来源:互联网 发布:js让一个div显示 编辑:程序博客网 时间:2024/05/17 23:04
WebScraping With Python读书笔记1
首先,下载最新版的BeautifulSoup。
4.4.1版本地址:https://www.crummy.com/software/BeautifulSoup/bs4/download/4.4/
BeautifuSoup主页:https://www.crummy.com/software/BeautifulSoup/
下载文件解压。
按照网上教程,将cmd的目录定位到解压缩文件夹地址,然后 >>python setup.py install
但是在IDLE中import bs4时,会出现:
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
import bs4
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35-32\lib\bs4\__init__.py", line 48
'You are trying to run the Python 2 version of Beautiful Soup under Python 3. This will not work.'<>'You need to convert the code, either by installing it (`python setup.py install`) or by running 2to3 (`2to3 -w bs4`).'
然后我又试了一下>>easy_setup.py,import bs4时报的错误却是:no such module.
解决办法:直接将压缩文件中的bs4复制到python安装目录下的lib中,然后再利用python自带工具2to3.py将版本2下的.py 文件转化为版本3下的文件。
具体:将bs4文件夹和2to3.py同时放到lib中,然后在cmd中定位到lib,运行:2to3.py bs4 -w就好了。
2to3.py位置:在python安装目录下的Tools/scripts/2to3.py。
2to3.py 用法:2to3.py param1 (-w)
param1 可以是要转换的.py文件,或者是文件夹,如果是文件夹,整个文件夹中的.py都会被转换。
-w可选,如果不写的话默认输出转换后的结果到显示屏,如果要把转换的文件再写入原文件,就需要加上。
现在,就可以from bs4 import BeautifulSoup了。
第一次写,不会截图,见谅。不过比stackflow上面的要详细多了,嘻嘻。
- 如何在Windows下,python3.5.1下安装BeautifuSoup。
- python3.5.2下安装BeautifuSoup--bs4
- Python3.6:Windows下如何安装matplotlib
- Python3在Windows下安装scrapy
- Python3在Windows下安装Scrapy
- windows系统下Python3.5.1安装教程
- windows下python3,Theano安装
- Windows:Python3下安装Scrapy
- Windows下python3安装Scrapy
- windows下安装python3.6
- windows下python3安装opencv
- python2.x 与 python3.x 在windows下如何共存
- Python2和Python3在Windows下共存的安装方法
- 在windows下python3.6 32bit安装scrapy
- windows系统64位—在python3下安装nltk
- 在Windows下同时安装Python2.x和Python3.x
- python3.6 在windows 系统下安装mysqldb
- Windows在Anaconda下安装Tensorflow Keras 支持Python3.6
- XAMPP 安装 LDAP
- 人工智能短故事:认知非连续Short Story on AI: A Cognitive Discontinuity
- 贪吃蛇
- 原型模式
- Eclipse开发前,常用设置
- 如何在Windows下,python3.5.1下安装BeautifuSoup。
- 循环神经网络The Unreasonable Effectiveness of Recurrent Neural Networks
- 编程小练习
- picker View控件使用
- 广东工业大学2016校赛决赛Problem BSward Art Online(分组背包)
- iOS AFN 做缓存(如何简单的做缓存)
- Centos 7 密码破解
- ROC曲线-阈值评价标准
- Tomcat清除缓存