Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Upgrade makes Code Error
#1
i upgrade (Clean install) python from 3.9 to 3.10.5
and try this code
import subprocess
subprocess.call("title Test pause & Pause")
then it failed:
Error:
Traceback (most recent call last): File "C:\Users\GIGABYTE\Desktop\test.py", line 2, in <module> subprocess.call("title Test pause & Pause") File "C:\Python\Python310\lib\subprocess.py", line 345, in call with Popen(*popenargs, **kwargs) as p: File "C:\Python\Python310\lib\subprocess.py", line 969, in __init__ self._execute_child(args, executable, preexec_fn, close_fds, File "C:\Python\Python310\lib\subprocess.py", line 1438, in _execute_child hp, ht, pid, tid = _winapi.CreateProcess(executable, args, FileNotFoundError: [WinError 2] The system cannot find the file specified
any clue to fix this?
Reply
#2
Try this perhaps
subprocess.call("title Test pause & Pause", shell=True)
If it works, read a tutorial about the subprocess module.
Reply
#3
(Jul-28-2022, 04:58 PM)Gribouillis Wrote: Try this perhaps
subprocess.call("title Test pause & Pause", shell=True)
If it works, read a tutorial about the subprocess module.
thank for the reply,
now the error does not appear,
and sadly the cmd window does not appear too
Reply
#4
I don't know the Windows OS, but you could perhaps call the 'cmd' command to open a cmd window, for example
subrocess.call(['cmd', '/k', 'title spam'])
or something similar.
Reply
#5
You should be using subprocess.run() instead of subprocess.call(). Subprocess.call() is the old Python 2.7 way of doing things.

Upgrading is not the source of your problem. I get the same error running with Python 3.9.
Reply
#6
(Jul-28-2022, 05:23 PM)Gribouillis Wrote: I don't know the Windows OS, but you could perhaps call the 'cmd' command to open a cmd window, for example
subrocess.call(['cmd', '/k', 'title spam'])
or something similar.
thank you, this the solution, I will give you a point
import subprocess
subprocess.call(['cmd', '/k', 'title Test pause & Pause & exit'])
Reply
#7
(Jul-28-2022, 05:26 PM)deanhystad Wrote: You should be using subprocess.run() instead of subprocess.call(). Subprocess.call() is the old Python 2.7 way of doing things.

Upgrading is not the source of your problem. I get the same error running with Python 3.9.
thank you, the call and run give same result as run, I will give you point too
import subprocess
subprocess.run(['cmd', '/k', 'title Test pause & Pause & exit'])
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  What a difference print() makes Mark17 2 581 Oct-20-2023, 10:24 PM
Last Post: DeaD_EyE
  Python Version upgrade nitinkukreja 1 913 Feb-04-2023, 10:27 PM
Last Post: Larz60+
  Tkinter + Multiprocessing startmap makes UI Freeze sunny9495 4 1,409 Nov-13-2022, 12:49 PM
Last Post: sunny9495
  pip doesn't work after Python upgrade Pavel_47 10 4,240 May-30-2022, 03:31 PM
Last Post: bowlofred
  Upgrade from 3.7.9 to 3.7.11 quazirfan 4 5,503 Sep-08-2021, 01:02 AM
Last Post: quazirfan
  Upgrade pip error karunas 3 3,164 Nov-26-2020, 11:40 AM
Last Post: buran
  Upgrade Python Version ? JohnnyCoffee 2 2,546 Aug-08-2020, 09:56 PM
Last Post: Larz60+
  pip upgrade error most197 4 5,323 May-08-2020, 05:35 PM
Last Post: snippsat
  Can't upgrade pip Josh_Python890 3 9,396 Sep-07-2019, 06:45 PM
Last Post: Josh_Python890
  help! this 'for' loop makes me crazy lerner50 5 2,946 Jul-09-2019, 03:39 PM
Last Post: perfringo

Forum Jump:

User Panel Messages

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