#pragma TextEncoding = "UTF-8" #pragma rtGlobals=3 // Use modern global access method and strict wave access #pragma DefaultTab={3,20,4} // Set default tab width in Igor Pro 9 and later //Change the file paths to the Anaconda activate bat file and the the python exe file. //Make sure Example.py and this ipf are in the same folder FUNCTION Call_Python() Print Secs2Time(DateTime, 3) String strPython_File_Name="Example.py" String strIpf_Folder_Path_Igor_Format=ParseFilePath(1, FunctionPath(""), ":", 1, 0) //Get the ipf folder path String strIpf_Folder_Path_Windows_Format=ParseFilePath(5, strIpf_Folder_Path_Igor_Format, "\\", 0, 0) //Convert to windows format String strBatch_File_Text="cd "+strIpf_Folder_Path_Windows_Format+"\r\n" //Set the current data folder to the folder with the ipf and py file //I found instructions for calling Anaconda from a batch file here: https://stackoverflow.com/questions/46305569/how-to-make-batch-files-run-in-anaconda-prompt //CHANGE THIS PATH TO MATCH THE ONE ON YOUR COMPUTER strBatch_File_Text+="call C:\Users\[INSERT USER NAME HERE]\AppData\Local\anaconda3\Scripts\activate.bat\r\n" //CHANGE THIS PATH TO MATCH THE ONE ON YOUR COMPUTER strBatch_File_Text+="C:\Users\[INSERT USER NAME HERE]\AppData\Local\anaconda3\python.exe " strBatch_File_Text+=strIpf_Folder_Path_Windows_Format+strPython_File_Name+" 105 -45 3" //Script to execute and user inputs for the script. Technically don't need to include the path to the script since it's in the current directory //Create batch file Variable vRefNum Open/Z vRefNum as strIpf_Folder_Path_Igor_Format+"Python_cmd.bat" fprintf vRefNum, strBatch_File_Text Close vRefNum ExecuteScriptText strIpf_Folder_Path_Windows_Format+"Python_cmd.bat" Print Secs2Time(DateTime, 3) END