gpt4 book ai didi

python - 在同一台机器 (OS X) 的 Python 2 和 Python 3 上安装 Beautiful Soup

转载 作者:太空宇宙 更新时间:2023-11-04 08:05:29 25 4
gpt4 key购买 nike

因此,我在 OS X 上安装 Beautiful Soup 时遇到了问题,最终在终端中测试了几种不同的安装方法。方法一:

python setup.py install

方法二:

easy_install BeautifulSoup

方法三:

pip install BeautifulSoup

最后我意识到问题是我在 PyCharm 中使用 Python 3 解释器,而 Beautiful Soup 安装在 OS X 附带的默认 Python 2 解释器上。在 PyCharm 中将解释器更改为 Python 2 使 Beautiful Soup 工作完美。

问题:我如何 - 在完整保留 OS X 的 Python 2 解释器的情况下 - 在 OS X 上的 Python 3 解释器上安装 Beautiful Soup?

最佳答案

PyCharm 自带 package installer .只需转到您的 Project Interpreter 页面并使用 + 按钮添加包。默认情况下,它将使用 PyPI 查找包。

请注意,您正在安装 BeautifulSoup 版本 3,它与 Python 3 不兼容。您需要 BeautifulSoup 4,名为 beautifulsoup4 .

如果 python3 在命令行上运行,您也可以使用:

python3 -m pip install beautifulsoup4

关于python - 在同一台机器 (OS X) 的 Python 2 和 Python 3 上安装 Beautiful Soup,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32005185/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com