使用Ubuntu16.04和Python3.5,我会得到一些包的导入错误。“BeautifulSoup4”或“请求”。这两个库都是从Ubuntu存储库安装的:
$ dpkg --get-selections | grep -E "python3-req|python3-bs"
python3-bs4 install
python3-requests install然而,我得到了"ImportError:没有名为‘BS4’/‘requests’的模块“。
$ python3 -c "import bs4"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named 'bs4'只有当我(另外!)通过pip3安装这些库--它可以工作。BeautifulSoup的文档说通过apt将其安装为"python3-bs4“。为什么它只适用于pip3方法?Python3-BS4/python3请求包的目的是什么?
发布于 2018-01-21 17:08:07
我解决了这个问题。
我仍然不太清楚到底是什么问题,但我怀疑pip3和apt相互混淆了实际安装的内容。pip3还列出了几个通过apt安装的python包。
我通过apt删除/清除了pip3 list识别的所有内容,也清除了pip3。然后,我apt install --reinstall以前给我带来麻烦的包: python3-bs4和python3-请求。requests库仍然无法工作,因为它错过了python3-six、python3-chardet和python3-urllib3包,这些包都是apt报告已经安装的包。apt install --reinstall也修复了这个问题。然后就成功了!
https://stackoverflow.com/questions/48227278
复制相似问题