python - 来自 bs4 的代码不起作用,尽管我已经尝试了它显示我需要转换代码的所有方法
问题描述
我在 Windows 10 上安装了 Python 3.7.4,然后添加了 Beautiful Soup 库。在导入它时,我收到以下错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python\lib\site-packages\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).
蚂蚁想法我能做些什么来解决这个问题?
解决方案
这是一个非常明确的错误信息:
您正在尝试在 Python 3 下运行 Python 2 版本的 Beautiful Soup。
这正是你想要做的。由于您可能安装了 Python 2 和 Python 3,请尝试安装 Beautiful Soup
pip3 install beautifulsoup4
pip3
适用pip
于 Python 3。
推荐阅读
- javascript - 承诺捕获问题
- centos - Percona XtraDB 集群:服务器退出而不更新 PID 文件...服务器启动失败
- swift - 如何根据 UIimageview 图像从一键播放声音
- ztree - 加载参数表
- python - 如何遍历字符串中的所有重叠匹配?
- azure - 需要帮助调查 Azure App Service .NET Core 2.1 ArgumentOutOfRangeException 和 System.OverflowException
- java - ActionBar内的后退按钮如何完成当前活动
- java - 如何将常量字段导出到 swagger ui?
- kubernetes - Kubernetes 命名空间中密码安全的重要性?
- ffmpeg - ffmpeg 将视频分割成 hls 切片,为什么 hls_time 选项不起作用?