python-3.xinstallationsite-packages

location of Python libraries installed


I have installed Python 3.8 in my machine (windows 10). I can see it is installed in following locations, and my Python programs are running fine, after adding these locations in PATH variable.

C:\Users\<user name>\AppData\Roaming\Python\Python38
C:\Users\<user name>\AppData\Local\Programs\Python\Python38

My questions:

  1. Why is it installed in a local directory as well as a roaming directory?
  2. In which directory I can find the source code of the functions like list append(), list insert(). I have tried looking for them in the site-package directory, but it has a huge number of sub-directories, and unable to figure out where exactly to find it.

Solution

  • To answer two of your questions:

    1. you can find the source code in: C:\Users<User>\AppData\Local\Programs\Python\Python39-32\Lib>

    2. you can run 'where' in WINDOWS terminal to find out which Python version installed. Also run these Python snippet to confirm:

    
        >>> import os
        >>> import sys
        >>> os.path.dirname(sys.executable)
        'C:\\Users\\<User>\\AppData\\Local\\Programs\\Python\\Python39-32'