From 6e4504297dc1dc57ed16be6f22d77889f105b297 Mon Sep 17 00:00:00 2001 From: Falko Habel Date: Fri, 15 Mar 2024 19:19:24 +0100 Subject: [PATCH] Error "Python" not supported on Linux. so cahnged to "Python3" --- main.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/main.go b/main.go index 8f3403d..c196843 100644 --- a/main.go +++ b/main.go @@ -70,8 +70,8 @@ func downloadPackages(w http.ResponseWriter, fromLanguage, toLanguage string) { // Use a goroutine for streaming responses so we can proceed with the download go streamResponse(w, fromLanguage, toLanguage, messages) - // Start the Python command in the background - cmd := exec.Command("python", "translator/download.py", fromLanguage, toLanguage) + // Start the python3 command in the background + cmd := exec.Command("python3", "translator/download.py", fromLanguage, toLanguage) output, err := cmd.StdoutPipe() if err != nil { messages <- fmt.Sprintf("Error starting Download: %s", err.Error()) @@ -95,7 +95,7 @@ func downloadPackages(w http.ResponseWriter, fromLanguage, toLanguage string) { } }() - // Read the output of the Python command and send it to the channel + // Read the output of the python3 command and send it to the channel scanner := bufio.NewScanner(output) firstOutputReceived := false for scanner.Scan() { @@ -124,8 +124,8 @@ func executeTranslator(w http.ResponseWriter, message, fromLanguage, toLanguage // A goroutine will manage sending streamed responses go streamResponse(w, fromLanguage, toLanguage, messages) - // Start the Python command in the background - cmd := exec.Command("python", "translator/translate.py", message, fromLanguage, toLanguage) + // Start the python3 command in the background + cmd := exec.Command("python3", "translator/translate.py", message, fromLanguage, toLanguage) output, err := cmd.StdoutPipe() if err != nil { messages <- fmt.Sprintf("Error starting Translation: %s", err.Error()) @@ -138,7 +138,7 @@ func executeTranslator(w http.ResponseWriter, message, fromLanguage, toLanguage return } - // Read the output of the Python command and send it through the channel + // Read the output of the python3 command and send it through the channel scanner := bufio.NewScanner(output) for scanner.Scan() { messages <- scanner.Text() // Sends each line of the output to the stream @@ -183,7 +183,7 @@ func CheckLanguagesInstalled(fromCode, toCode string) (bool, error) { return false, nil } func getAllPackages() error { - cmd := exec.Command("python", "translator/note_all_packages.py") + cmd := exec.Command("python3", "translator/note_all_packages.py") // Create a buffer to capture the standard output. var out bytes.Buffer cmd.Stdout = &out @@ -247,7 +247,7 @@ func main() { http.HandleFunc("/api", handleRequest) // Get the port number from the environment variable or use a default value - port := "11435" + port := "53184" if p := os.Getenv("PORT"); p != "" { port = p }