在同一台机器的 Python 2 和 Python 3 上安装 Beautiful Soup (OS X)
Installing Beautiful Soup both on Python 2 and Python 3 in the same machine (OS X)
所以,我在 OS X 上安装 Beautiful Soup 时遇到了问题,最终在终端中测试了几种不同的安装方法。方法一:
python setup.py install
方法二:
easy_install BeautifulSoup
方法三:
pip install BeautifulSoup
最后我意识到问题是我在 PyCharm 中使用 Python 3 解释器,而 Beautiful Soup 安装在默认的 Python 2 解释器上 OS X. 在 PyCharm 中将解释器更改为 Python 2 使 Beautiful Soup 完美运行。
问题:
我怎样才能 - 在 OS X 的 Python 2 解释器完好无损的情况下 - 在 OS X 上的 Python 3 解释器上安装 Beautiful Soup?
PyCharm 自带 package installer。只需转到您的项目解释器页面并使用 +
按钮添加包。它默认使用 PyPI 来查找包。
请注意,您正在安装 BeautifulSoup 版本 3,它与 Python 3 不兼容。您想要 BeautifulSoup 4,名为beautifulsoup4
.
如果 python3
在命令行上工作,您也可以只使用:
python3 -m pip install beautifulsoup4
所以,我在 OS X 上安装 Beautiful Soup 时遇到了问题,最终在终端中测试了几种不同的安装方法。方法一:
python setup.py install
方法二:
easy_install BeautifulSoup
方法三:
pip install BeautifulSoup
最后我意识到问题是我在 PyCharm 中使用 Python 3 解释器,而 Beautiful Soup 安装在默认的 Python 2 解释器上 OS X. 在 PyCharm 中将解释器更改为 Python 2 使 Beautiful Soup 完美运行。
问题: 我怎样才能 - 在 OS X 的 Python 2 解释器完好无损的情况下 - 在 OS X 上的 Python 3 解释器上安装 Beautiful Soup?
PyCharm 自带 package installer。只需转到您的项目解释器页面并使用 +
按钮添加包。它默认使用 PyPI 来查找包。
请注意,您正在安装 BeautifulSoup 版本 3,它与 Python 3 不兼容。您想要 BeautifulSoup 4,名为beautifulsoup4
.
如果 python3
在命令行上工作,您也可以只使用:
python3 -m pip install beautifulsoup4