Executing Python script from VB.NET project

แชร์
ฝัง
  • เผยแพร่เมื่อ 31 ม.ค. 2025

ความคิดเห็น • 15

  • @peters972
    @peters972 ปีที่แล้ว

    thank you!

  • @ashharansari1434
    @ashharansari1434 4 ปีที่แล้ว +1

    I am getting an error with "System.ComponentModel.Win32Exception: 'The system cannot find the file specified'" can you please tell how to resolve this I am new to the vb

    • @xspydazx
      @xspydazx ปีที่แล้ว

      @@pikas_coffee_boutique Public Function RunCmdPrompt(ByVal _Cmd As String) As String
      Dim start_info As New ProcessStartInfo("cmd.exe", "/c " & _Cmd) With {
      .UseShellExecute = False,
      .CreateNoWindow = True,
      .RedirectStandardOutput = True,
      .RedirectStandardInput = True,
      .RedirectStandardError = True
      }
      ' Make the process and set its start information.
      Dim proc As New Process With {
      .StartInfo = start_info
      }
      ' Start the process.
      proc.Start()
      ' Attach to stdout and stderr.
      Dim std_out As IO.StreamReader = proc.StandardOutput()
      Dim std_err As IO.StreamReader = proc.StandardError()
      If std_out IsNot Nothing Then
      ' Display the results.
      Dim result As String = std_out.ReadToEnd()
      ' Clean up.
      std_out.Close()
      proc.Close()
      Return result
      Else
      ' Display the results.
      Dim iresult As String = std_err.ReadToEnd()
      ' Clean up.
      std_out.Close()
      proc.Close()
      Return iresult
      End If
      End Function

  • @khalidalkin
    @khalidalkin 4 ปีที่แล้ว +1

    Thanks for the vid however I can't execute python script after publishing the application any tips?

    • @vladi3471
      @vladi3471  4 ปีที่แล้ว

      Hello! not sure what do you mean by "publishing". create(build) .exe file? Just checked,works fine. have you tried this from comments below? Thanks!
      The script (in this example it's just a text file with .py extension and command: print("Hello Python") has to be in same directory,where your VB project is(not python.exe). in this example location of the script was C:\Users\User_Name\source
      epos\WindowsApp24\WindowsApp24\bin\Debug\Hello.py

  • @dr.fatmagamal784
    @dr.fatmagamal784 5 ปีที่แล้ว +1

    thanks so much for your effort, i tried it and when executing the code was error free but textbox1 didn't contain the results,

    • @vladi3471
      @vladi3471  5 ปีที่แล้ว +1

      Hello! The script (in this example it's just a text file with .py extension and command: print("Hello Python") has to be in same directory,where your VB project is(not python.exe). in this example location of the script was C:\Users\User_Name\source
      epos\WindowsApp24\WindowsApp24\bin\Debug\Hello.py

    • @vladi3471
      @vladi3471  5 ปีที่แล้ว

      I'm stuck (and kind of abandoned the whole thing) because I couldn't find a way to change the conda environments and call the scripts from VB that are created for different than conda "base" environment. and even if for example Tensorflow or Keras are installed in conda "base" environment the scripts,that are calling those libraries won't execute. If you , or anyone, by any chance find a solution please explain it here or create your own video. I'm very new to the Python and can't find anything in relation to VB + Python combo.Thank you!

    • @dr.fatmagamal784
      @dr.fatmagamal784 5 ปีที่แล้ว +1

      @@vladi3471 it worked!!!!!!!!!!!!!!!!! i don't know how to thank u

    • @dr.fatmagamal784
      @dr.fatmagamal784 5 ปีที่แล้ว +1

      @@vladi3471 i'm new too to vb with python and you were the first one who was able to help me

    • @vladi3471
      @vladi3471  5 ปีที่แล้ว +1

      @@dr.fatmagamal784 I'm glad I was able to help,but if by any chance you see something similar to what I described above can you please share ? Link or whatever. Because sooner or later you will run into same problem. Thanks!

  • @andresfranco7480
    @andresfranco7480 3 ปีที่แล้ว

    muchas gracias.

  • @sportford75
    @sportford75 5 ปีที่แล้ว +1

    Спасибо было очень интересно жаль нечего не понял 🧐🤡😂

    • @vladi3471
      @vladi3471  5 ปีที่แล้ว

      я сам такой же. ковыряюсь в потемках