Please see the instructions in the CASA Documentation, https://casadocs.readthedocs.io/en/stable/api/configuration.html#startup-py
The 'startup.py' file found in $HOME/.casa (i.e. ~/.casa/startup.py) is evaluated by the CASA shell just before the CASA prompt is presented to the user. This allows users to customize their CASA shell environment beyond the standard settings in 'config.py', by importing packages, setting variables or modifying the python system path.
One case where this is useful is for configuring CASA for ALMA data reduction. A package called 'analysisUtils' is often used as part of ALMA analysis. It is typically imported and instantiated in startup.py:
$ cat ~/.casa/startup.py import sys, os sys.path.append("/home/casa/contrib/AIV/science/analysis_scripts/") import analysisUtils as aUes = aU.stuffForScienceDataReduction()
In this example, the standard python modules os and sys are made available in the CASA shell. The path where the analysisUtils module can be found is added to the Python system path, and finally the package is imported and an object is created. These modules and objects will then be available for the user within the CASA shell environment.