简体   繁体   English

如何在还安装了Python 3.4的情况下为Python 2.7安装BeautifulSoup4?

[英]How to install BeautifulSoup4 for Python 2.7 while also having Python 3.4 installed?

I have both Python 2.7.11 and Python 3.4.1 installed on my Windows 8.1 system. 我在Windows 8.1系统上安装了Python 2.7.11和Python 3.4.1。 I had installed BeautifulSoup4 with pip to run a code (not mine). 我已经用pip安装BeautifulSoup4来运行代码(不是我的)。 However, pip automatically installed bs4 to Python 3.4.1. 但是,pip自动将bs4安装到Python 3.4.1。 (I checked that it was installed in C://Python34/lib/site-packages/bs4 ) (我检查了它是否已安装在C://Python34/lib/site-packages/bs4

I have use the command prompt, change directory to C:\\Python27 (where Python 2.7 is installed), and pip install bs4 from that directory, but it didn't work. 我已经使用命令提示符,将目录更改为C:\\ Python27(已安装Python 2.7的目录),并从该目录pip安装bs4,但是没有用。 I had copied the bs4 folder from Python 3.4, but it didn't work either. 我已经从Python 3.4复制了bs4文件夹,但是它也不起作用。 It only gave another Import Error: No module named html.entities. 它只给出了另一个导入错误:没有名为html.entities的模块。

How can I install bs4 on Python 2.7? 如何在Python 2.7上安装bs4? Thanks in advance. 提前致谢。

我猜你可以运行pip2 install bs4pip3 install bs4分别在不同的python版本上安装它们

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM