簡體   English   中英

當默認目錄為python2.7時,如何將beautifulsoup安裝到python3中?

[英]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 目錄中?

我認為 pip3 將滿足您的需求,請在終端上使用以下命令:

pip3 install beautifulsoup4

文檔

以 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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM