2

A few days ago I was getting issues trying to run Tensorflow models with CUDA enabled and for a long time I couldn't resolve in large because PyCharm displayed completely unhelpful message

"Process finished with exit code -1073740791 (0xC0000409)"

I then launched VSCode and ran the same code in PowerShell and got a nice and extensive error message which allowed me to resolve all issues within half hour (same when running in cmd too). Other outputs are also somewhat different. So this makes me assume that PyCharm runs scripts in some type of its own terminal rather than relying on cmd or PowerShell.

Does anyone know if this is the case?

2
  • Where you using a virtual environment in PyCharm? If you go to File>Settings... what's Python Interpreter set to? Commented May 9, 2021 at 23:57
  • 1
    "Process finished with exit code" means that there is something wrong with the environment configured to execute your code. It's not an error in your code. Specifically speaking 0xC0000409 means STATUS_STACK_BUFFER_OVERRUN. Commented May 10, 2021 at 0:01

1 Answer 1

1

So this makes me assume that PyCharm runs scripts in some type of its own terminal rather than relying on cmd or PowerShell.

Not necessarily. Just because PyCharm displays a custom error message doesn't mean it doesn't rely on cmd. Here's a Python script that simulates what PyCharm does using the cmd:

# So we can launch a process from Python
import subprocess as sp

# Launches a Python process for a specific file
# `stdout=sp.DEVNULL` suppresses the process output
# so that's why there is no detailed error message
child = sp.Popen(["python", "file.py"], stdout=sp.DEVNULL)

# Start the Python process
process = child.communicate()[0]

# Returns the process exit code
# If the process finishes without errors, it'll return 0
# otherwise, it'll return a "random" value
exit_code = process.returncode

# Displays to stdout the completely unhelpful message
print(f"Process finished with exit code {exit_code} ({hex(exit_code)})")

Either way, here's what PyCharm says:

Initially, the terminal emulator runs with your default system shell, but it supports many other shells such as Windows PowerShell, Command Prompt cmd.exe, sh, bash, zsh, csh, and so on.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, That's what I wanted to find out. So PyCharm essentially runs a subprocess and only captures the exit code in case of system errors. Now this makes sense.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.