Python庫的位置

Augustone發表於2024-08-31

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

相關文章