如何在 Mac 上安装 selenium python

How to install selenium python on Mac

我已经下载了 python 的 Selenium zip 文件,它包含带有 setup.py 的文件夹。它在 python.org 上说我必须输入终端 'python setup.py install' 但它给了我这个错误,我需要成为管理员,因为我没有目录的权限,而实际上我的用户已经是管理员:

Checking .pth file support in /Library/Python/2.7/site-packages/
error: can't create or remove files in install directory

The following error occurred while trying to add or remove files in the
installation directory:

[Errno 13] Permission denied: /Library/Python/2.7/site-packages/test-easy-install-1469.pth'

The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:

/Library/Python/2.7/site-packages/

Perhaps your account does not have write access to this directory?  If the
installation directory is a system-owned directory, you may need to sign in
as the administrator or "root" account.  If you do not have administrative
access to this machine, you may wish to choose a different installation
directory, preferably one that is listed in your PYTHONPATH environment
variable.

For information on other options, you may wish to consult the
documentation at:

  https://pythonhosted.org/setuptools/easy_install.html

Please make the appropriate changes for your system and try again.`

我不想触及 Mac 的默认设置 python。相反,我建议您自己酿造 python

https://brew.sh/

安装 brew

然后安装 python

brew install python3

然后安装selenium

pip3 install selenium