1,操作系统命令行看系统python的库
where python
C:\Users\augus\AppData\Local\Microsoft\WindowsApps\python.exe
>>> for item in sys.path:
... print(item)
...
C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.1520.0_x64__qbz5n2kfra8p0\python312.zip
C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.1520.0_x64__qbz5n2kfra8p0\DLLs
C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.1520.0_x64__qbz5n2kfra8p0\Lib
C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.1520.0_x64__qbz5n2kfra8p0
C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.1520.0_x64__qbz5n2kfra8p0\Lib\site-packages
2,如果使用了虚拟环境(系统+虚拟环境)
2.1,在pycharm的控制台(系统+虚拟环境+项目环境)
PyDev console: starting.
Python 3.12.5 (tags/v3.12.5:ff3bc82, Aug 6 2024, 20:45:27) [MSC v.1940 64 bit (AMD64)] on win32
import sys
for item in sys.path:
print(item)
C:\Program Files\JetBrains\PyCharm Community Edition 2024.2\plugins\python-ce\helpers\pydev
C:\Program Files\JetBrains\PyCharm Community Edition 2024.2\plugins\python-ce\helpers\third_party\thriftpy
C:\Program Files\JetBrains\PyCharm Community Edition 2024.2\plugins\python-ce\helpers\pydev
C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.1520.0_x64__qbz5n2kfra8p0\python312.zip
C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.1520.0_x64__qbz5n2kfra8p0\DLLs
C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.1520.0_x64__qbz5n2kfra8p0\Lib
C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.1520.0_x64__qbz5n2kfra8p0
C:\Users\augus\PycharmProjects\pythonProject\.venv
C:\Users\augus\PycharmProjects\pythonProject\.venv\Lib\site-packages
C:\Users\augus\PycharmProjects\pythonProject\.venv\Lib\site-packages\setuptools\_vendor
C:\Users\augus\PycharmProjects\pythonProject
2.2,在pycharm的os控制台
(.venv) PS C:\Users\augus\PycharmProjects\pythonProject> python
Python 3.12.5 (tags/v3.12.5:ff3bc82, Aug 6 2024, 20:45:27) [MSC v.1940 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> for item in sys.path:
... print(item)
...
C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.1520.0_x64__qbz5n2kfra8p0\python312.zip
C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.1520.0_x64__qbz5n2kfra8p0\DLLs
C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.1520.0_x64__qbz5n2kfra8p0\Lib
C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.1520.0_x64__qbz5n2kfra8p0
C:\Users\augus\PycharmProjects\pythonProject\.venv
C:\Users\augus\PycharmProjects\pythonProject\.venv\Lib\site-packages
2.3,在pycharm程序中(系统+虚拟环境+项目环境)
C:\Users\augus\PycharmProjects\pythonProject\.venv\Scripts\python.exe C:\Users\augus\PycharmProjects\pythonProject\检查python\库位置.py
C:\Users\augus\PycharmProjects\pythonProject\检查python
C:\Users\augus\PycharmProjects\pythonProject
C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.1520.0_x64__qbz5n2kfra8p0\python312.zip
C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.1520.0_x64__qbz5n2kfra8p0\DLLs
C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.1520.0_x64__qbz5n2kfra8p0\Lib
C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.1520.0_x64__qbz5n2kfra8p0
C:\Users\augus\PycharmProjects\pythonProject\.venv
C:\Users\augus\PycharmProjects\pythonProject\.venv\Lib\site-packages