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

 在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



猜你喜欢

转载自blog.csdn.net/lypgcs/article/details/78026047