pip install selenium 出現錯誤 error: externally-managed-environment

輸入指令 pip install selenium
error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
python3-xyz, where xyz is the package you are trying to

If you wish to install a non-Debian-packaged Python package,
create a virtual environment using python3 -m venv path/to/venv.
Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
sure you have python3-full installed.

If you wish to install a non-Debian packaged Python application,
it may be easiest to use pipx install xyz, which will manage a
virtual environment for you. Make sure you have pipx installed.

See /usr/share/doc/python3.11/README.venv for more information.

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing –break-system-packages.
hint: See PEP 668 for the detailed specification.

mkdir -p ~/.config/pip/
cd ~/.config/pip/
vi pip.conf

break-system-packages = true

pip install selenium
Defaulting to user installation because normal site-packages is not writeable
Collecting selenium
Downloading selenium-4.16.0-py3-none-any.whl (10.0 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 10.0/10.0 MB 5.5 MB/s eta 0:00:00
Requirement already satisfied: urllib3[socks]<3,>=1.26 in /usr/lib/python3/dist-packages (from selenium) (1.26.12)
Collecting trio~=0.17
Downloading trio-0.23.1-py3-none-any.whl (448 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 448.3/448.3 kB 8.5 MB/s eta 0:00:00
Collecting trio-websocket~=0.9
Downloading trio_websocket-0.11.1-py3-none-any.whl (17 kB)
Requirement already satisfied: certifi>=2021.10.8 in /usr/lib/python3/dist-packages (from selenium) (2022.9.24)
Collecting attrs>=20.1.0
Downloading attrs-23.1.0-py3-none-any.whl (61 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 61.2/61.2 kB 3.9 MB/s eta 0:00:00
Collecting sortedcontainers
Downloading sortedcontainers-2.4.0-py2.py3-none-any.whl (29 kB)
Requirement already satisfied: idna in /usr/lib/python3/dist-packages (from trio~=0.17->selenium) (3.3)
Collecting outcome
Downloading outcome-1.3.0.post0-py2.py3-none-any.whl (10 kB)
Collecting sniffio>=1.3.0
Downloading sniffio-1.3.0-py3-none-any.whl (10 kB)
Collecting wsproto>=0.14
Downloading wsproto-1.2.0-py3-none-any.whl (24 kB)
Collecting PySocks!=1.5.7,<2.0,>=1.5.6
Downloading PySocks-1.7.1-py3-none-any.whl (16 kB)
Collecting h11<1,>=0.9.0
Downloading h11-0.14.0-py3-none-any.whl (58 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 58.3/58.3 kB 6.7 MB/s eta 0:00:00
Installing collected packages: sortedcontainers, sniffio, PySocks, h11, attrs, wsproto, outcome, trio, trio-websocket, selenium
Successfully installed PySocks-1.7.1 attrs-23.1.0 h11-0.14.0 outcome-1.3.0.post0 selenium-4.16.0 sniffio-1.3.0 sortedcontainers-2.4.0 trio-0.23.1 trio-websocket-0.11.1 wsproto-1.2.0

問題已解決, 確認一下
pip list
Package Version
—————— ———–
attrs 23.1.0
Brlapi 0.8.4
certifi 2022.9.24
chardet 5.1.0
charset-normalizer 3.0.1
cupshelpers 1.0
dbus-python 1.3.2
distro 1.8.0
feedparser 6.0.10
h11 0.14.0
httplib2 0.20.4
idna 3.3
louis 3.24.0
musicbrainzngs 0.7.1
mutagen 1.46.0
outcome 1.3.0.post0
pip 23.0.1
psutil 5.9.4
pycairo 1.20.1
pycups 2.0.1
pycurl 7.45.2
PyGObject 3.42.2
pyinotify 0.9.6
pyparsing 3.0.9
PySimpleSOAP 1.16.2
pysmbc 1.0.23
PySocks 1.7.1
python-apt 2.6.0
python-debian 0.1.49
python-debianbts 4.0.1
pyxdg 0.28
quodlibet 4.5.0
reportbug 12.0.0
requests 2.28.1
selenium 4.16.0
setuptools 66.1.1
sgmllib3k 1.0.0
six 1.16.0
sniffio 1.3.0
sortedcontainers 2.4.0
trio 0.23.1
trio-websocket 0.11.1
urllib3 1.26.12
wheel 0.38.4
wsproto 1.2.0
xdg 5

selenium 4.16.0 <—確認無誤



發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *