python3 安装 Beautifulsoup4 版本不兼容问题
来源:互联网 发布:模拟炒股软件 mac 编辑:程序博客网 时间:2024/05/29 03:37
注意我的python的windows安装目录为:D:\Python37-32
python进行爬虫时引用到BeautifuSoup开源的xml解析工具。以下为beautifulsoup4的windows的安装步骤:
首先去网站下载beautifulsoup压缩包(beautifulsoup4-4.6.0.tar.gz)
https://www.crummy.com/software/BeautifulSoup/#Download
将下载下来的压缩包解压后放入到python的安装目录(D:\Python37-32\beautifulsoup4-4.6.0)
进入cmd,执行命令:
cd D:\Python37-32\beautifulsoup4-4.6.0setup.py buildsetup.py install输入验证是否安装成功:
在命令行输入:python
然后输入:from bs4 import BeautifulSoup
如果不出现任何提示信息表示安装成功。如果如下所示则安装失败,版本不兼容
在python3中引用BeautifuSoup4时会出现版本不兼容的情况,具体看下面的错误代码
>>> from bs4 import BeautiulSoupTraceback (most recent call last): File "<stdin>", line 1, in <module> File "D:\Python37-32\beautifulsoup4-4.6.0\bs4\__init__.py", line 53 '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`).' ^SyntaxError: invalid syntax
将beautifulSoup解压目录中的bs4文件夹(D:\Python37-32\beautifulsoup4-4.6.0\bs4)和 2to3.py(D:\Python37-32\Tools\scripts\)复制到python的安装目录下的Lib(D:\Python37-32\Lib)文件夹下
进入D:\Python37-32\Lib 目录,并执行 2to3.py bs4 -w 命令
cd D:\Python37-32\Lib2to3.py bs4 -w最后再输入python
然后输入 from bs4 import BeautifulSoup
阅读全文
0 0
- python3 安装 Beautifulsoup4 版本不兼容问题
- python3 安装 Beautifulsoup4结果发现版本不兼容的问题解决
- CentOS下安装Python3后BeautifulSoup 版本不兼容问题解决方法
- Python3安装BeautifulSoup4模块
- MAC 为python3安装 beautifulsoup4
- visual studio2017 python3安装beautifulsoup4
- MAC 为python3安装 beautifulsoup4
- Python3.X Windows平台 安装BeautifulSoup4
- Python2和Python3共存时安装BeautifulSoup4
- DLL版本不兼容问题
- DLL版本不兼容问题
- jstl版本不兼容问题
- log4net版本不兼容问题
- eclipse安装fatjar插件方法及版本不兼容问题解决
- mac ox上安装jdk 7版本不兼容问题
- Ubuntu安装faster-rcnn编译caffe版本不兼容问题
- Ubuntu系统上Python2和Python3共存时安装BeautifulSoup4
- Python进阶(十九)-Python3安装第三方爬虫库BeautifulSoup4
- poj 2289 二分图多重匹配
- 1016. 部分A+B (15)
- 第二课 检索数据
- 强连通分量
- HDOJ1040
- python3 安装 Beautifulsoup4 版本不兼容问题
- 数字记忆小游戏
- [莫比乌斯反演] 51Nod 1355 斐波那契的最小公倍数
- Visiting Peking University 2017ACM-ICPC亚洲区(北京赛区)网络赛题目1
- 多自由度平衡稳定性
- Hibernate外键一对一单向和双向关联的理解
- ubuntu server 16.04.2 编译使用mod_shout
- HTTPS 原理及安全加密方案
- 268. Missing Number