[Tips] Where Is Python Module Directory?

GOAL

To find the directory where python libraries are.

Method

Use sys.path

You can get the list of module search paths. Find the directory you’d like from the list.

>python
Python 3.8.6
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
---The list of module search paths---

Appendix

You can find the directory where python.exe is by using “where” command.

>where python
C:\Users\<USER_NAME>\AppData\Local\Microsoft\WindowsApps\python.exe
C:\Python27\python.exe