python3 beautifulSoup 支持问题
来源:互联网 发布:大淘客口令源码下载 编辑:程序博客网 时间:2024/05/29 04:38
按照网上教程,将cmd的目录定位到解压缩文件夹地址,然后 >>python setup.py install
(
Window下不能直接解压tar.giz文件,可以使用7z解压软件提取解压再在CMD下打开
)
但是在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了。
- python3 beautifulSoup 支持问题
- beautifulsoup 4来了,支持python3.x
- BeautifulSoup Python3
- Python3 win7安装BeautifulSoup
- Python3 win7安装BeautifulSoup
- Python3 BeautifulSoup pymysql
- python3.5安装BeautifulSoup
- python3.X下面安装BeautifulSoup
- 【问题】使用BeautifulSoup解析在python2和python3下表现不一样?
- python3 终端下英汉词典 BeautifulSoup+网络爬虫
- python3 终端下英汉词典 BeautifulSoup+网络爬虫
- python3+BeautifulSoup+tkinter 爬虫 获取学校成绩
- beautifulsoup,python3中的爬虫匹配神器
- python3 beautifulsoup查找网页中的链接
- python3.3 lxml+beautifulsoup 爬虫说明
- python3安装beautifulsoup包的方法
- Python3.6安装 pip安装 BeautifulSoup安装
- Python3 BeautifulSoup爬虫 POJ自动提交
- 发现了以元素 'property' 开头的无效内容。应以....
- spring读写分离
- WEB前端常用框架
- 求二叉树高度
- 将JDK安装版改成非安装版
- python3 beautifulSoup 支持问题
- 链表的初始化、遍历、删除、插入、判断是否为空、求长度 C语言实现
- JDK7中Executor源码概述
- csv文件导入mysql数据库
- 什么是WTL?
- java object类中的默认方法
- 市面上的BT内核和p2p播放器源码
- CUICatalog: Invalid asset name supplied: '' 解决办法
- Hadoop 读写文件源码分析