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
  problem in running a code akbarza 7 543 Feb-14-2024, 02:57 PM
Last Post: snippsat
  writing and running code in vscode without saving it akbarza 1 344 Jan-11-2024, 02:59 PM
Last Post: deanhystad
  the order of running code in a decorator function akbarza 2 478 Nov-10-2023, 08:09 AM
Last Post: akbarza
  error "cannot identify image file" part way through running hatflyer 0 613 Nov-02-2023, 11:45 PM
Last Post: hatflyer
  Error when running kivy on python janeik 8 1,923 Jun-16-2023, 10:58 PM
Last Post: janeik
  Getting error when running "MINUS" between 2 databases marlonbown 4 1,217 Nov-10-2022, 05:49 AM
Last Post: deanhystad
  Code running many times nad not just one? korenron 4 1,324 Jul-24-2022, 08:12 AM
Last Post: korenron
  Pandas - error when running Pycharm, but works on cmd line zxcv101 1 1,321 Jun-18-2022, 01:09 PM
Last Post: snippsat
  Error when running a matplot lib example aurelius_nero 3 6,686 Apr-24-2022, 01:24 PM
Last Post: Axel_Erfurt
  code running for more than an hour now, yet didn't get any result, what should I do? aiden 2 1,421 Apr-06-2022, 03:41 PM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

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