[英]How to install beautifulsoup into python3, when default dir is python2.7?
我安装了 Python 2.7 和 Python 3.5。 当我输入pip install beautifulsoup4
它告诉我它已经安装在 python2.7/site-package 目录中。
但是如何将它安装到 python3 目录中?
以 root 身份运行:
apt-get install python3-bs4
#or
pip3 install beautifulsoup4
然后像这样导入它:
import bs4
如果您使用的是最新版本的 Debian 或 Ubuntu Linux,您可以使用系统包管理器安装 Beautiful Soup:
$ apt-get install python-bs4 (for Python 2)
$ apt-get install python3-bs4 (for Python 3)
安装后导入库
from bs4 import BeautifulSoup
该软件包是 bs4,可以使用以下命令安装:
python -m pip install bs4
如果您在 Windows 上,这也适用于 Python3 py -m pip install bs4
我在 Python 版本和 Beautifulsoup 之间有些不匹配。 我正在将此项目Th3Jock3R/LinuxGSM-Arma3-Mod-Update安装到 linux centos8 专用 Arma3 服务器。 Python3 和 Beautifulsoup4 似乎匹配。所以我更新了 Python3,手动删除了 Beautifulsoup 文件并重新安装: sudo yum install python3-beautifulsoup4 (注意数字 3)。 作品。 只需在 Th3Jock3R:s 脚本 A3_SERVER_FOLDER = "" 和 A3_SERVER_DIR = "/home/arma3server/serverfiles/{}".format(A3_SERVER_FOLDER) 中指向目录并通过python3 update.py在同一文件夹中运行脚本现在 mod 加载的轻量级让我大吃一惊。 -鲍勃-
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.