A portable, Windows, Python environment bundled with CWMS libraries and dependencies.
- WinPython 3.12.10.1: Portable Python distribution
- Pre-installed Libraries: All dependencies from
requirements_binary_only.txt - Custom Configuration: CWMS-specific setup and utilities
- Jython installer script: An installer that will download this python from the CWMS CAVI and setup user environment variables.
Open the CAVI and script editor.
Make a new script in the CAVI called install_python.
Go to the install_python.py script in the jython_scripts folder and copy the raw script.

Paste the script into the script window.

Click Save/Run to launch the installer.
Click Install Portable Python to install. Please be patient, it may take up to 10 minutes to install.
Note: if you get a "Failed to download configuration" error with the jython installer, try replacing the Config URL: path with a link to the pythonCWMS_config.json file in the latest release (e.g. ./releases/tag/v0.81/pythonCWMS_config.json) and reload the configuration. This error can occur if the rawgithub content is blocked.
You can also just download the latest release file (e.g. pythonCWMS1.01.7z (https://github.com/USACE-WaterManagement/pythonCWMS/releases/)) and unzip the portable python distribution and setup your user environment variables yourself to add the python to your path.
- Use
pythonCWMSin the command line to run python. - Setup the default python in VsCode by pointing the []
python.defaultInterpreterPath] (https://code.visualstudio.com/docs/python/settings-reference) to the installation directory (e.g.C:\hec\python\pythonCWMS\python). - Run
WinPython Command Prompt.exefor command line access - Run
WinPython Interpreter.exefor Python IDLE - Or use
pythonCWMS.batfor the custom CWMS environment
To have VS Code default to this portable python, open Preferences: Open User Settings (JSON) by pressing Cntr+Shift+P and searching for Preferences in the search bar at the top of VS Code.

In your settings.json file, put in this "python.defaultInterpreterPath": "${env:PYTHON_CWMS_HOME}\\python.exe" or this "python.defaultInterpreterPath": "C:\\hec\\python\\pythonCWMS\\python\\python.exe".
When working with a repo VSCode sometimes has trouble finding the interprator (e.g. python notebook w/ shared workspace). Try searching for Python: Clear Workspace Interpreter Setting by pressing Cntr+Shift+P and searching for Preferences in the search bar at the top of VS Code.

-
To install additional libraries beyond what is in the requirements_binary_only.txt file, open the WinPython powershell included in your python (e.g.
C:\hec\python\pythonCWMS\WinPython Powershell Prompt.exe) and do a pip install from there. -
The command
pythonCWMS -m pip install my_package_to_installwill also work
To use the python environment in the CAVI, a jython launcher script is used to run the python script as a subprocess. The jython script can also pass arguments to the python script.
- To run a python script in the CAVI, edit the
python_script_pathandargsvariables in theexample_python_script_launcher.pyjython script to point to your python script and save in the CAVI script editor. You can pass arguments from your jython environment (e.g. watershed path etc...), but this is optional. LeaveargsasNoneor''if arguments are not needed. - Output of the python script will be passed to the CAVI console after the process is completed.
See CONTRIBUTING.md



