WSL Ubuntu中NWChem如何配置Windows绝对路径适配MoCalc2012?
Great question! The core issue here is that MoCalc2012 expects a valid Windows file path (a physical executable or script file), but wsl nwchem is just a command-line invocation—not a file path it can recognize. Here's a simple, reliable fix that bridges this gap:
Step 1: Create a Windows Batch File
Open Notepad and paste the following code:
@echo off wsl nwchem %*
Save this file as nwchem.bat in a directory you can easily access (for example, C:\WSLApps\—feel free to create this folder if it doesn't exist). Make sure you save it as a .bat file, not a .txt file: in Notepad's "Save As" dialog, set "Save as type" to "All Files" to avoid accidental formatting.
Step 2: Test the Batch File
Open a Windows Command Prompt and run the full path to your new batch file:
C:\WSLApps\nwchem.bat
If this launches NWChem via WSL just like wsl nwchem did, you're good to go. The %* in the batch file ensures any command-line arguments MoCalc2012 sends will be passed directly to NWChem in WSL, so all your calculations will work as expected.
Step 3: Update MoCalc2012's Path Setting
In MoCalc2012's configuration where you need to enter the NWChem path, paste the full absolute path to your nwchem.bat file (e.g., C:\WSLApps\nwchem.bat). MoCalc will recognize this as a valid Windows file path, and when it runs the batch file, it'll trigger the WSL NWChem invocation under the hood.
Bonus Tip
If you want to make this batch file accessible system-wide (so you can run nwchem from any Command Prompt without typing the full path), add the directory containing nwchem.bat to your Windows PATH environment variable. But for MoCalc's purposes, just the full absolute path to the bat file is all you need.
内容的提问来源于stack exchange,提问作者S. OConnor

