0

I have installed Python directly on a flash drive and my references within my modules all use the full path (on the flash drive) to operate. My IDLE window is not displaying the execution of my code.

I have a Python Script named: test.py which contains the following code:

 print('Hello')

 from win32com.client import Dispatch

 xl = Dispatch("Excel.Application")
 xl.Visible = True # otherwise excel is hidden

If I run the script from the Editor using: Run -> Run Module, the Excel Workbook opens successfully and the Python IDLE will display the following:

====================== RESTART: D:\MICK\Scripts\test.py ======================
Hello
>>> 

Test 2: Now, If I use Windows+R and run: D:\MICK\Scripts\test.py, the Excel Workbook opens successfully but the IDLE does not even open.

Test 3: I manually open the IDLE (located at: D:\MICK\Anaconda\Lib\idlelib\idle.pyw) and I use Windows+R to run:D:\MICK\Scripts\test.py. The Excel workbook opens, but the IDLE stays blank:

Python 3.5.2 |Anaconda 4.2.0 (32-bit)| (default, Jul  5 2016, 11:45:57) [MSC v.1900 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> 

What could be causing interference between Windows+R called scripts and Run-> Run module called scripts?

3
  • how do you run script ? Commented Dec 31, 2016 at 1:28
  • Normally, one does not run .py with Window's Run dialog box but call the script with a true terminal: CMD prompt or Powershell. Had you done so, the terminal would show Hello and launch Excel. Commented Dec 31, 2016 at 2:29
  • Hi, you are right, when I run the same problematic Script from Powershell, I do see Hello in the PowerShell terminal. Thank you, that did bring some info to the table. Commented Dec 31, 2016 at 4:23

1 Answer 1

1

When you use Win-R, do you notice the command prompt window open and close quickly? You can see that this is what is happening byby opening a command prompt and running this as well, and noting that the "Hello" will be shown on the command prompt.

IDLE is an IDE, not a python interpreter. When you run it from the editor, it's specially wired to run in IDLE.

You shouldn't expect things to run in IDLE, unless you explicitly invoke IDLE.

When you try to run D:\MICK\Scripts\test.py, what's actually happening is Windows is looking for the handler for files with a 'py' extension, and then running the appropriate item, in this case python, so you're likely getting something like python D:\MICK\Scripts\test.py, which you'll note is not invoking IDLE.

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

2 Comments

Hi, I do see a black terminal window open and close right away. Are you saying that Hello would be written in that window? Maybe I am confusing the IDLE and the Interpreter?
Yes, the hello is being output there. Like I said, you can verify this yourself by running the "Command Prompt" and running the script.

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.