Python Forum
Error while running code on VSC
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Error while running code on VSC
#1
I have installed python3, however while running below code snippet in the VS Code terminal getting an error as system could not find the path.
import sys
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *

def window():
    app = QApplication(sys.argv)
    w = QWidget()
    b = QPushButton(w)
    b.setText('show message!')
    w.setWindowTitle('PyQt dialog demo')
    b.move(250, 250)
    b.clicked.connect(showdialog)
    w.show()
    sys.exit(app.exec())

def showdialog():
    msg = QMessageBox()
    msg.setIcon(QMessageBox.Information)
    msg.setText('This is a message box')
    msg.setInformativeText('This is additional information ')
    msg.setWindowTitle('messagebox demo')
    msg.setDetailedText('the details are as follows')
    msg.setStandardButtons(QMessageBox.Open | QMessageBox.Apply)
    msg.buttonClicked.connect(msgbtn)

    retval = msg.exec_()
    print('value of pressed message box button is: ', retval)

def msgbtn(i):
    print('button pressed is: ', i.text())

if __name__ == '__main__':
    window()
This is the error am getting
Error:
PS C:\Users\maiya\Desktop\test> python3 buttonapp.py Program 'python3.exe' failed to run: The system cannot find the path specifiedAt line:1 char:1 + python3 qthread_app.py + ~~~~~~~~~~~~~~~~~~~~~~. At line:1 char:1 + python3 qthread_app.py + ~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ResourceUnavailable: (:) [], ApplicationFailedException + FullyQualifiedErrorId : NativeCommandFailed PS C:\Users\maiya\Desktop\test>
python.exe is installed in the
Quote:C:\Program Files\Python310
also set the system variable path as well.
Quote:C:\Program Files\Python310\Scripts\
any support on this would be really appreciated. Thanks a lot.
Regards,
Maiya
Reply
#2
It's not python3 on Windows just python
Test that work from command line.
G:\div_code
λ python -V
Python 3.10.5

G:\div_code
λ python -c "import sys; print(sys.executable)"
C:\python310\python.exe

G:\div_code
λ pip -V
pip 22.0.4 from C:\Python310\lib\site-packages\pip (python 3.10)
Then in VS Code down in right corner see that same Python interpreter is chosen.
Reply
#3
(Jul-01-2022, 12:27 PM)snippsat Wrote: It's not python3 on Windows just python
Test that work from command line.
G:\div_code
λ python -V
Python 3.10.5

G:\div_code
λ python -c "import sys; print(sys.executable)"
C:\python310\python.exe

G:\div_code
λ pip -V
pip 22.0.4 from C:\Python310\lib\site-packages\pip (python 3.10)
Then in VS Code down in right corner see that same Python interpreter is chosen.

Hi snippsat,

Thanks for your quick response. Every thing else is correct, however
python -c "import sys; print(sys.executable)"
output for the above import print is as below, not expected result.
Output:
C:\Users\maiya>python3 -c "import sys; print(sys.executable)" The system cannot find the file C:\Users\maiyapr\AppData\Local\Microsoft\WindowsApps\python3.exe. C:\Users\maiya>
Even in VS Code is selected python interpreter from the C:\python310\python.exe location only.
Reply
#4
You have written python3 again🧬
Reply
#5
(Jul-01-2022, 02:25 PM)snippsat Wrote: You have written python3 again🧬

oh! yeah you are right.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Photo Running Brackets code Jojogeno 2 89 Feb-13-2026, 10:30 AM
Last Post: buran
  Error running 'main' Siondonsen 1 731 Jul-29-2025, 05:03 PM
Last Post: deanhystad
  code not running even without errors Azdaghost 2 1,080 Apr-25-2025, 07:35 PM
Last Post: Azdaghost
  python code not running Azdaghost 1 828 Apr-22-2025, 08:44 PM
Last Post: deanhystad
  writing and running code in vscode without saving it akbarza 5 4,895 Mar-03-2025, 08:14 PM
Last Post: Gribouillis
  Pandas - error when running Pycharm, but works on cmd line zxcv101 2 3,595 Sep-09-2024, 08:03 AM
Last Post: pinkang
  problem in running a code akbarza 7 3,348 Feb-14-2024, 02:57 PM
Last Post: snippsat
  the order of running code in a decorator function akbarza 2 1,969 Nov-10-2023, 08:09 AM
Last Post: akbarza
  error "cannot identify image file" part way through running hatflyer 0 2,678 Nov-02-2023, 11:45 PM
Last Post: hatflyer
  Error when running kivy on python janeik 8 9,357 Jun-16-2023, 10:58 PM
Last Post: janeik

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020