- 通过导入 python 系统包输出安装路径:
(base) *@* bin % python
Python 3.9.12 (main, Apr 5 2022, 01:52:34)
[Clang 12.0.0 ] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print(sys.path)
['', '/*/*/*/lib/python39.zip', '/*/*/*/lib/python3.9', '/*/*/*/lib/python3.9/lib-dynload', '/*/*/*/lib/python3.9/site-packages']
一定要导入 sys 包,否则会提示:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'sys' is not defined
- 使用 “whereis” 命令:
(base) *@* bin % whereis python
python: /*/*/*/bin/python