首页 > 解决方案 > 无法将 Beautiful Soup 安装到 Python 2,因为我已经在我的 Python 3 中安装了它,但我也无法导入或卸载它

问题描述

我最近不得不恢复到 Python 2.7 才能在 ArcMap 中工作。我尝试安装 Beautiful Soup,但由于我已经在 Python 3 中安装了它,它声称“要求已经满足”;但是,我不能导入任何模块,因为它当然是安装在 Python 3 中而不是 Python 2 中。

我试过卸载了,又找不到了。捕获 22。

尝试安装 -

d:\egm722>pip install beautifulsoup4

已满足要求:c:\users\geo\appdata\local\prog rams\python\python37-32\lib\site-packages 中的 beautifulsoup4 (4.6.3)

尝试进口——

import bs4 Traceback(最近一次调用最后一次):文件“”,第 1 行,在 ImportError 中:没有名为 bs4 的模块来自 bs4 import beautifulsoup Traceback(最近一次调用最后一次):文件“”,第 1 行,在 ImportError 中:没有名为 bs4 的模块

尝试卸载 -

d:\egm722>pip uninstall BeautifulSoup 跳过 BeautifulSoup,因为它没有安装。

我宁愿不恢复到 Python 3 并从那里卸载,所以任何关于如何在我目前的状态下执行它的建议将不胜感激。当谈到 Python 时,我是一个新手,尤其是不同的环境,所以请放轻松。

标签: pythonbeautifulsoup

解决方案


您需要具体说明pip您要使用哪个,以确保使用与您的 Python 2 安装相关联的那个。尝试:

pip2 install beautifulsoup4

或者

python2 -m pip install beautifulsoup4

或者,如果 Python 2 是您系统上的默认 python,您可以运行

python -m pip install beautifulsoup4

推荐阅读