You are trying to run the Python 2 version of Beautiful Soup under Python 3. This will not work.

来源:互联网 发布:男士护肤套装 知乎 编辑:程序博客网 时间:2024/06/05 03:23

 在python3下直接使用安装的BeautifulSoup包会提示下面这段错误:

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`)

解决方案之一:

beautifulsoup文件夹下的bs4转换成python3的版本即可,

使用python3安装目录下lib文件夹中的2to3命令

如果将python3添加到了环境变量中则可以直接使用命令,如果没有则需要定位到python3安装目录下的lib目录

2to3 /beautifulsoup/bs4(beautifulsoup安装目录下的bs4) -w



阅读全文
0 0