Short Description
I'm using PyCharm and am writing a pytest unit test.
I can run the test normally but if I try to debug it the debugger crashes.
Windows fatal exception: access violation
Stack Trace:
Thread 0x00003588 (most recent call first):
File "C:\Users\MyUserName\AppData\Local\Programs\Python\Python310\lib\threading.py", line 324 in wait
File "C:\Users\MyUserName\AppData\Local\Programs\Python\Python310\lib\threading.py", line 600 in wait
File "C:\Program Files\JetBrains\PyCharm 2021.1\plugins\python\helpers\pydev\pydevd.py", line 150 in _on_run
File "C:\Program Files\JetBrains\PyCharm 2021.1\plugins\python\helpers\pydev_pydevd_bundle\pydevd_comm.py", line 218 in run
File "C:\Users\MyUserName\AppData\Local\Programs\Python\Python310\lib\threading.py", line 1009 in _bootstrap_inner
File "C:\Users\MyUserName\AppData\Local\Programs\Python\Python310\lib\threading.py", line 966 in _bootstrap
Thread 0x000023f0 (most recent call first):
File "C:\Program Files\JetBrains\PyCharm 2021.1\plugins\python\helpers\pydev_pydevd_bundle\pydevd_comm.py", line 292 in _on_run
File "C:\Program Files\JetBrains\PyCharm 2021.1\plugins\python\helpers\pydev_pydevd_bundle\pydevd_comm.py", line 218 in run
File "C:\Users\MyUserName\AppData\Local\Programs\Python\Python310\lib\threading.py", line 1009 in _bootstrap_inner
File "C:\Users\MyUserName\AppData\Local\Programs\Python\Python310\lib\threading.py", line 966 in _bootstrap
...
File "C:\Program Files\JetBrains\PyCharm 2021.1\plugins\python\helpers\pydev_pydev_imps_pydev_execfile.py", line 18 in execfile
File "C:\Program Files\JetBrains\PyCharm 2021.1\plugins\python\helpers\pydev\pydevd.py", line 1483 in _exec
File "C:\Program Files\JetBrains\PyCharm 2021.1\plugins\python\helpers\pydev\pydevd.py", line 1476 in run
File "C:\Program Files\JetBrains\PyCharm 2021.1\plugins\python\helpers\pydev\pydevd.py", line 2164 in main
File "C:\Program Files\JetBrains\PyCharm 2021.1\plugins\python\helpers\pydev\pydevd.py", line 2173 in
Process finished with exit code -1073741819 (0xC0000005)
Disabling all breakpoints fixed it for me:
Then I was able to set new ones.
For me moving from python 3.10 to 3.9 solved the issue.
Removing the breakpoints did not solve this for me. Moving from Python 3.10 to Python 3.11 did.
Related
I'm trying to run a simple windows command dir E:\Projects\ML /s /b using subprocess.Popen function without using Shell=True, my sample program is below
import subprocess
import os
import time
input='E:\Projects\ML'
command = "dir "+input+' /s /b '
os.system(command)
status=subprocess.Popen(command.split(' '),shell=False,text=True,cwd=input,stdout=subprocess.PIPE)
while status.wait()!=0:
time.sleep(1)
print(status.communicate())
with os.system() the command is giving appropriate results but with Popen() I'm facing below problem
Traceback (most recent call last):
File "e:\Projects\ArchiveViewer\PythonR&D\EncriptionWithPopen\runLocalCMD.py", line 9, in <module>
status=subprocess.Popen(command.split(' '),shell=False,text=True,cwd=input,stdout=subprocess.PIPE)
File "C:\Users\nmaiya\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 951, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Users\nmaiya\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 1420, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified
I know that if I set shell=True the command will run, but is there any reason why it is not working with shell=Fales
dir is an internal command inside cmd.exe, there is no dir.exe that can be started as a process.
system("xyz") is internally executed as something like cmd.exe /C xyz on Windows.
I have a batch file that executes these commands:
set repodir=D:\Folder
cd /d %repodir%
call "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\vcvarsall.bat" x86_amd64
tf undo * /recursive /noprompt
tf get
I want to achieve same functionality from shell script. I am able to change the directory path to wherever code is present
Problems:
command call is not found - read that I need to use . operator in shell script. Tried this but not working. Error is "#echo command not found" in vcvarsall.bat ( the first line in that file is #echo off )
. "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\vcvarsall.bat" x86_amd64
Since calling batch file is failing in step 2, command tf is not found
tf undo * /recursive /noprompt
tf get
Environment: I am trying to run the shell script using cygwin on Windows Server 2008
Remove the 'call' because that is for calling one bat file from another.
Specify the full path for tf.exe. Of course that will vary depending on the version of TFS you have installed.
After installed XboxOneADK, there will be a Xbox One ADK Command Prompt.
its target is below:
C:\Windows\system32\cmd.exe /k "C:\Program Files (x86)\Microsoft Durango XDK\adk\DurangoVars.cmd" ADK
Then it can run as a new cmd window. And I can run command in this cmd window.
C:\Program Files (x86)\Microsoft Durango XDK\bin>xbapp.exe xxxxxx
C:\Program Files (x86)\Microsoft Durango XDK\bin>Makepkg.exe xxxxxx
...
I dont't like it's too manual.
How can I run only one command to launch the ADK cmd window with xbapp.exe and Makepkg.exe commands?
Thank you!
Prepare a text file with this contents:
example.txt:
"C:\Program Files (x86)\Microsoft Durango XDK\adk\DurangoVars.cmd" ADK
xbapp.exe xxxxxx
Makepkg.exe xxxxxx
...
exit
And "execute it" this way:
cmd < example.txt
I have read everywhere that the subprocess module is the best way to use the command line from Python, but I'm having trouble making it work. I have a firefox extension called Page Saver that saves an image of an entire webpage. On the comand line, this command successfully saves an image:
firefox -savepng "http://www.google.com"
I've tried this script to automate the process, but no luck:
import subprocess
subprocess.call(['firefox', '-savepng', 'http://www.google.com'], shell=False)
I get this error:
Traceback (most recent call last):
File "C:/Users/computer_4/Desktop/Scripts/crescentsaver.py", line 2, in <module>
subprocess.call(['firefox', '-savepng', 'http://www.google.com'], shell=False)
File "C:\Python27\lib\subprocess.py", line 524, in call
return Popen(*popenargs, **kwargs).wait()
File "C:\Python27\lib\subprocess.py", line 711, in __init__
errread, errwrite)
File "C:\Python27\lib\subprocess.py", line 948, in _execute_child
startupinfo)
WindowsError: [Error 2] The system cannot find the file specified
Am I using subprocess incorrectly?
Thanks.
Update:
Found the solution. It was a little detail of the extension I was using. The script had to be run from the Firefox default saves folder to work. I also ran the parameters as a string, not a list, with shell=True:
import subprocess
subprocess.call('firefox -savepng http://www.google.com', shell=True)
I could not answer my own question due to the limitation on new users answering their own questions within eight hours of posting.
What subprocess.call() is telling you with that error is that it cannot find the firefox command on your PATH. (Which is a list of directories where Windows searches for commands).
So you have two options here:
Specify the full path to the Firefox command in your script: this is easy, just put the full path in your python code.
Add the directory that contains the Firefox command to your PATH. This is a little more complicated but you can find a decent tutorial on Super User
How can I use the devenv.com to show the output in command line window as well as an external log file. I am using the following command line for building a solution file:
devenv.com /Build "Release|Win32" SolutionFile.sln >> D:\SolutionLog.log
Using the above command line the output is written only to the SolutionLog.log file and not to the command line. How can I modify the above command to get the command in command line as well as to an external log file.
Try the /out parameter:
devenv.com /Build "Release|Win32" SolutionFile.sln /out D:\SolutionLog.log