[英]BeautifulSoup4 is not working even though I have successfully installed it using pip Linux Mint Sarah
I am a brand new linux user using linux mint sarah and I just installed python 3.5 as well as BeautifulSoup to do some web scraping. 我是一个使用linux mint sarah的全新Linux用户,我刚刚安装了python 3.5以及BeautifulSoup来进行一些网络抓取。
However, when I type in the following command I receive a traceback error: 但是,当我键入以下命令时,我收到回溯错误:
from bs4 import BeautifulSoup 从bs4导入BeautifulSoup
The error tells me that there is no module bs4. 该错误告诉我没有模块bs4。
I have also tried: import bs4 from BeautifulSoup import BeautifulSoup import beautifulsoup 我也尝试过:从BeautifulSoup导入bs4导入BeautifulSoup导入beautifulsoup
This is weird because if I go into terminal and give the command pip list, it shows me a list of all my programs and it states that I have beautifulsoup4 (4.5.1) 这很奇怪,因为如果我进入终端并给出命令点列表,它会向我显示所有程序的列表,并指出我有beautifulsoup4(4.5.1)
I successfully used pip in the same exact way to install a module called requests and it was successful. 我以相同的方式成功地使用了pip来安装名为请求的模块,并且成功。
One thing that I think may be getting in the way is that Linux mint comes with python 2.7 installed and my modules are going into a 2.7 folder which seems odd. 我认为可能会遇到的一件事是,Linux mint附带安装了python 2.7,而我的模块进入了2.7文件夹,这似乎很奇怪。 (However, the requests module that I can successfully use is in the same folder as the BeautifulSoup4 module)
(但是,我可以成功使用的请求模块与BeautifulSoup4模块在同一文件夹中)
I must admit I have not tried easy_install because it gives me some error about the directory not existing when I try to install BeautifulSoup4 that way. 我必须承认我没有尝试过easy_install,因为当我尝试以这种方式安装BeautifulSoup4时,它给我关于目录不存在的错误。
I'm muddying the waters too much so I will leave it at that. 我把水弄得太多了,所以我就不用管它了。 Hopefully, somebody can help me figure out whats going on so that people who have this problem in the future can benefit.
希望有人可以帮助我弄清楚发生了什么事,以便将来有此问题的人都能从中受益。
Thanks! 谢谢!
You need to install BeautifulSoup4 for Python 3.5 . 您需要为Python 3.5安装BeautifulSoup4 。
Option 1: 选项1:
python3 get-pip.py
python3 get-pip.py
pip3 install beautifulsoup4
pip3 install beautifulsoup4
Option 2: 选项2:
Extract tar.gz: tar -xvzf beautifulsoup4-4.5.1.tar.gz
提取tar.gz:
tar -xvzf beautifulsoup4-4.5.1.tar.gz
Go to folder: cd beautifulsoup4-4.5.1/
转到文件夹:
cd beautifulsoup4-4.5.1/
Install from source: python3 setup.py install
从源安装:
python3 setup.py install
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.