Unable to initialize device PRN in Python

Unable to initialize device PRN in Python

I had this same problem when I accidentally typed print program.py instead of python program.py. The error message comes from the Windows command-line program named print. Those who suggested restarting the command prompt probably committed the same typo without noticing, and corrected it in their new command prompt.

I know this is an old question, but I experienced this issue in VS Code after installing the latest version of Python and the Python extension.

To fix it, I just needed to add the Python installation path to my PATH environment variable.

  • On Windows 10, go to Settings and search for Environment
  • Click on Edit environment variables for your account
  • Select Path and click the Edit button
  • If the path to your Python.exe is not listed, click the New button
  • Enter the path to your Python.exe application and click the OK button
    • The path for me was %LocalAppData%ProgramsPythonPython37-32
  • Restart VS Code and try to run your python script again

Unable to initialize device PRN in Python

In my case restarting (close / open new) the console or the Command Prompt window works

Leave a Reply

Your email address will not be published. Required fields are marked *