I've had great success using PyInstaller to compile the .py script and all its necessary components into a single executable that I can then run in Windows Task Scheduler. This frees you from worrying how to call a particular virtual environment. This also allows you to share the executable with different systems without setting up that same Python environment. I have found a significant resulting .exe size if the API was installed with or without dependencies. If you install the arcgis package using the default command (e.g. conda install -c esri arcgis or pip install arcgis ) the resulting .exe file size can be > 200 MB. Installing without dependencies (e.g. conda install -c esri arcgis --no-deps or pip install arcgis --no-deps ) the resulting .exe file size can be < 40 MB. It may not be possible to install without dependencies in your case but I would recommend doing so if you can. PyInstaller Compiling Snippet: import subprocess env = <Enter the path to your virtual environment.> fn = <Enter the desired output file name.> py = <Enter the path to your .py script.> subprocess.check_call(f"{env}/Scripts/pyinstaller -n {fn} -F {py}")
... View more