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.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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.
1
2
3
4
5
6
7
8
9
10
11
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.
1
2
3
4
5
6
7
8
9
10
11
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
1
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
  python code not running Azdaghost 1 86 9 hours ago
Last Post: deanhystad
  writing and running code in vscode without saving it akbarza 5 2,370 Mar-03-2025, 08:14 PM
Last Post: Gribouillis
  Pandas - error when running Pycharm, but works on cmd line zxcv101 2 2,423 Sep-09-2024, 08:03 AM
Last Post: pinkang
  problem in running a code akbarza 7 2,325 Feb-14-2024, 02:57 PM
Last Post: snippsat
  the order of running code in a decorator function akbarza 2 1,345 Nov-10-2023, 08:09 AM
Last Post: akbarza
  error "cannot identify image file" part way through running hatflyer 0 1,992 Nov-02-2023, 11:45 PM
Last Post: hatflyer
  Error when running kivy on python janeik 8 5,461 Jun-16-2023, 10:58 PM
Last Post: janeik
  Getting error when running "MINUS" between 2 databases marlonbown 4 2,252 Nov-10-2022, 05:49 AM
Last Post: deanhystad
  Code running many times nad not just one? korenron 4 2,201 Jul-24-2022, 08:12 AM
Last Post: korenron
  Error when running a matplot lib example aurelius_nero 3 10,103 Apr-24-2022, 01:24 PM
Last Post: Axel_Erfurt

Forum Jump:

User Panel Messages

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