Reputation: 347
I attempt to run a python program and the following pops up in command prompt:
"Unable to initialize device PRN"
I should also mention that the program runs fine.
Upvotes: 33
Views: 178419
Reputation: 169
I had the same problem when using Netstat print route in order to view the routing table. It gave the error: 'Unable to initialize device PRN' . It disappeared when I used the equivalent netstat -r (and it did print out the routing table)
Upvotes: 1
Reputation: 11
Please try to enter python in terminal and then execute the same command . In terminal type "Python" then run the command print("Hi"). It will work.
Upvotes: 0
Reputation: 8142
I encountered this in VS Code. I had run some lines of code (using Shift + Enter), which starts a Python interpreter in a terminal, and then I called quit()
at the terminal, to exit Python. If you try to run some more lines of code, it doesn't start another Python interpreter, it just runs those lines in the terminal, which of course doesn't work and causes error messages like the one in the question.
Two easy solutions are either to start a new Python interpreter in the terminal (by entering python
), or killing the active terminal instance (the dustbin icon), before running more lines of code.
Upvotes: 5
Reputation: 51
First of all install latest version of Python from it's official website (i.e. python.org/download) after that if you try to run it through command prompt instead of writing python3 just write python. After that >> it will appear then start writing your actual code. Make sure you re-run the command prompt window.
Upvotes: 3
Reputation: 13516
I had the same problem by accidentally sending the word "print" to the command line from my programming which DOS interprets as the DOS command to print to the printer.
Upvotes: 2
Reputation: 21
I am using VS code and I just noticed this issue today. Google a little and I comment out all the print function still not working. I exit the vs code and launch it again and it works just perfectly.
Upvotes: 1
Reputation: 1
To fix this, add python.exe to system varible in your windows 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 and restart the application
Upvotes: 0
Reputation: 3777
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%\Programs\Python\Python37-32\
- Restart VS Code and try to run your python script again
Upvotes: 5
Reputation: 881
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.
Upvotes: 78
Reputation: 11
Try changing name of the program; that worked for me. Don't forget: use fresh cmd when you start executing.
Upvotes: 1
Reputation: 301
In my case restarting (close / open new) the console or the Command Prompt window works
Upvotes: 2