#-------------------------------------------------------------------------------
#  [1] Python3 initialization:
#
#      Follow "MacStdUser-ReadMeFirst.txt" to set up the OS-standard Python3.
#-------------------------------------------------------------------------------
MacBookPro2{kazzz-s} ~ (1)% which python3
/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/bin/python3

MacBookPro2{kazzz-s} ~ (2)% python3
Python 3.9.6 (default, Feb  3 2024, 15:58:28)
[Clang 15.0.0 (clang-1500.3.9.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> quit()


#-------------------------------------------------------------------------------
#  [2] Installation process of different Python modules using 'pip':
#      Let's install [pandas, scipy, matplotlib], for example.
#-------------------------------------------------------------------------------
MacBookPro2{kazzz-s} ~ (3)% python3 -m pip list
                            ^^^^^^^^^^^^^^^^^^^
Package    Version
---------- -------
altgraph   0.17.2
future     0.18.2
macholib   1.16.3
pip        21.2.4
setuptools 58.0.4
six        1.16.0
wheel      0.44.0

MacBookPro2{kazzz-s} ~ (4)% sudo python3 -m pip install pandas scipy matplotlib
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Password:
WARNING: The directory '/Users/sekigawa/Library/Caches/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you should use sudo's -H flag.
Collecting pandas
  Downloading pandas-2.2.3-cp39-cp39-macosx_10_9_x86_64.whl (12.6 MB)
     |████████████████████████████████| 12.6 MB 76 kB/s
:
:

MacBookPro2{kazzz-s} ~ (5)% python3 -m pip list
                            ^^^^^^^^^^^^^^^^^^^
Package             Version
------------------- -----------
altgraph            0.17.2
contourpy           1.3.0
cycler              0.12.1
fontools            0.6.1
fonttools           4.53.1
future              0.18.2
importlib_metadata  8.5.0
importlib_resources 6.4.5
kiwisolver          1.4.7
klayout             0.29.6
macholib            1.16.3
markdown-it-py      3.0.0
matplotlib          3.9.2
mdurl               0.1.2
numpy               2.0.2
packaging           24.1
pandas              2.2.3
pillow              10.4.0
pip                 21.2.4
pyarrow             17.0.0
pyfaidx             0.8.1.2
pyfnutils           1.4
Pygments            2.18.0
pyparsing           3.1.4
PyPDF2              3.0.1
python-dateutil     2.9.0.post0
pytz                2024.2
rich                13.8.1
scipy               1.13.1
setuptools          58.0.4
six                 1.16.0
tzdata              2024.1
wheel               0.44.0
zipp                3.20.2
zstandard           0.23.0

Note that these packages are located under "/Library/Python/3.9/site-packages" like:

MacBookPro2{kazzz-s} site-packages (6)% pwd
/Library/Python/3.9/site-packages

MacBookPro2{kazzz-s} site-packages (7)% ll
```
total 44
drwxr-xr-x  80 root wheel  2560  9 23 11:41 .
drwxr-xr-x   5 root wheel   160  8  1 18:36 ..
drwxr-xr-x 113 root wheel  3616  7  5 19:03 PIL
drwxr-xr-x   4 root wheel   128  9 21 11:07 _distutils_hack
drwxr-xr-x   9 root wheel   288  9 21 11:06 altgraph
drwxr-xr-x  10 root wheel   320  9 21 11:06 altgraph-0.17.4.dist-info
drwxr-xr-x  11 root wheel   352  8  1 18:36 benchmarks
drwxr-xr-x  38 root wheel  1216  8  1 18:36 cmake_modules
drwxr-xr-x  15 root wheel   480  9  8 18:46 contourpy
drwxr-xr-x   8 root wheel   256  9  8 18:46 contourpy-1.3.0.dist-info
drwxr-xr-x   4 root wheel   128  2 16  2024 cycler
drwxr-xr-x   8 root wheel   256  2 16  2024 cycler-0.12.1.dist-info
drwxr-xr-x  13 root wheel   416  3  5  2024 dateutil
-rw-r--r--   1 root wheel   151  9 21 11:07 distutils-precedence.pth
drwxr-xr-x   6 root wheel   192  8  1 18:36 examples
drwxr-xr-x   6 root wheel   192  7  6 07:26 fontTools
drwxr-xr-x  11 root wheel   352  7  6 07:24 fontools
drwxr-xr-x  10 root wheel   320  7  6 07:24 fontools-0.6.1.dist-info
drwxr-xr-x  11 root wheel   352  7  6 07:24 fontools_scripts
drwxr-xr-x  10 root wheel   320  7  6 07:24 fonttools-4.53.1.dist-info
drwxr-xr-x  10 root wheel   320  9 21 11:07 future
drwxr-xr-x  10 root wheel   320  9 21 11:07 future-1.0.0.dist-info
drwxr-xr-x  13 root wheel   416  9 21 11:07 importlib_metadata
drwxr-xr-x   9 root wheel   288  9 21 11:07 importlib_metadata-8.5.0.dist-info
drwxr-xr-x  14 root wheel   448  9 21 11:07 importlib_resources
drwxr-xr-x   9 root wheel   288  9 21 11:07 importlib_resources-6.4.5.dist-info
drwxr-xr-x   7 root wheel   224  9  8 18:46 kiwisolver
drwxr-xr-x   9 root wheel   288  9  8 18:46 kiwisolver-1.4.7.dist-info
drwxr-xr-x  36 root wheel  1152  8  1 18:36 klayout
drwxr-xr-x   9 root wheel   288  8  1 18:36 klayout-0.29.5.dist-info
drwxr-xr-x   6 root wheel   192  9 21 11:07 libfuturize
drwxr-xr-x   5 root wheel   160  9 21 11:07 libpasteurize
drwxr-xr-x  19 root wheel   608  3  5  2024 macholib
drwxr-xr-x  11 root wheel   352  3  5  2024 macholib-1.16.3.dist-info
drwxr-xr-x 149 root wheel  4768  8 15 21:40 matplotlib
drwxr-xr-x   8 root wheel   256  8 15 21:40 matplotlib-3.9.2.dist-info
drwxr-xr-x   5 root wheel   160  8 15 21:40 mpl_toolkits
drwxr-xr-x  47 root wheel  1504  8  1 18:36 numpy
drwxr-xr-x   9 root wheel   288  8  1 18:36 numpy-2.0.1.dist-info
drwxr-xr-x  17 root wheel   544  3 15  2024 packaging
drwxr-xr-x  10 root wheel   320  3 15  2024 packaging-24.0.dist-info
drwxr-xr-x  22 root wheel   704  9 23 11:42 pandas
drwxr-xr-x   9 root wheel   288  9 23 11:42 pandas-2.2.3.dist-info
drwxr-xr-x   7 root wheel   224  9 21 11:07 past
drwxr-xr-x  10 root wheel   320  7  5 19:03 pillow-10.4.0.dist-info
drwxr-xr-x   8 root wheel   256  9 21 11:05 pip
drwxr-xr-x  11 root wheel   352  9 21 11:05 pip-24.2.dist-info
drwxr-xr-x   6 root wheel   192  9 21 11:07 pkg_resources
drwxr-xr-x   3 root wheel    96  8  1 18:36 pya
drwxr-xr-x 117 root wheel  3744  8  1 18:36 pyarrow
drwxr-xr-x  10 root wheel   320  8  1 18:36 pyarrow-17.0.0.dist-info
drwxr-xr-x   4 root wheel   128  8 15 21:40 pyfaidx
drwxr-xr-x  10 root wheel   320  8 15 21:40 pyfaidx-0.8.1.2.dist-info
drwxr-xr-x   6 root wheel   192  7  6 07:24 pyfnutils
drwxr-xr-x   8 root wheel   256  7  6 07:24 pyfnutils-1.4.dist-info
-rw-r--r--   1 root wheel   110  8 15 21:40 pylab.py
drwxr-xr-x  14 root wheel   448  3 15  2024 pyparsing
drwxr-xr-x   8 root wheel   256  3 15  2024 pyparsing-3.1.2.dist-info
drwxr-xr-x  10 root wheel   320  3  5  2024 python_dateutil-2.9.0.post0.dist-info
drwxr-xr-x   9 root wheel   288  9 21 11:06 pytz
drwxr-xr-x  10 root wheel   320  9 21 11:06 pytz-2024.2.dist-info
drwxr-xr-x  81 root wheel  2592  9 21 11:07 rich
drwxr-xr-x   8 root wheel   256  9 21 11:07 rich-13.8.1.dist-info
drwxr-xr-x  30 root wheel   960  4  7 22:17 scipy
drwxr-xr-x   8 root wheel   256  4  7 22:17 scipy-1.13.0.dist-info
drwxr-xr-x   5 root wheel   160  8  1 18:36 scripts
drwxr-xr-x  49 root wheel  1568  9 21 11:07 setuptools
drwxr-xr-x  10 root wheel   320  8 15 21:40 setuptools-72.2.0.dist-info
drwxr-xr-x  10 root wheel   320  9 21 11:07 setuptools-75.1.0.dist-info
drwxr-xr-x   9 root wheel   288  3  5  2024 six-1.16.0.dist-info
-rw-r--r--   1 root wheel 34549  3  5  2024 six.py
drwxr-xr-x   5 root wheel   160  2 16  2024 tzdata
drwxr-xr-x   9 root wheel   288  2 16  2024 tzdata-2024.1.dist-info
drwxr-xr-x  13 root wheel   416  8 15 21:40 wheel
drwxr-xr-x   9 root wheel   288  8 15 21:40 wheel-0.44.0.dist-info
drwxr-xr-x   5 root wheel   160  9 21 11:06 zipp
drwxr-xr-x   9 root wheel   288  8 15 21:41 zipp-3.20.0.dist-info
drwxr-xr-x   9 root wheel   288  9 21 11:06 zipp-3.20.2.dist-info
drwxr-xr-x   8 root wheel   256  8  1 18:36 zstandard
drwxr-xr-x   9 root wheel   288  8  1 18:36 zstandard-0.23.0.dist-info
```


#-------------------------------------------------------------------------------
#  [3] Python module import test:
#
#      Run this sample python from "Macro Development" with such a sample CSV.
#-------------------------------------------------------------------------------
'''
# Enter your Python code here
import os
import numpy as np
import scipy
import matplotlib
import pandas as pd

sampleCSV = os.environ["HOME"] + "/KLayout/sampleCSV.csv"
df = pd.read_csv( sampleCSV, comment='#' )
print(df)
'''

== Output ==
      X[mm]  Y[mm]   Ratio[]
0       0.0    3.1  1.006617
1       2.7   -1.5  1.006607
2      -2.7   -1.5  1.006321
3       0.0    9.2  1.006651
4       5.9    7.0  1.006211
...     ...    ...       ...
1805  -30.3  140.7  0.994904
1806  -24.3  141.9  0.994266
1807  -18.3  142.8  0.994888
1808  -12.2  143.4  0.994146
1809   -6.1  143.11  0.993552

[1810 rows x 3 columns]

#------------------
# End of File
#------------------
