0

I have a python file that works correctly every time when run from the command line as "python file.py", but doesn't work properly when I run it with the python command line utility by double clicking it.Is there some environmental differences between the two methods of running the program?

Edit: The program is a packet sniffing utility (using scapy.sniff()) that sends results using a twisted server. The sniffing filter selects the correct packets when run from the command line, but not when opened in the python command line tool.

3
  • 1
    How is it failing when you double click it? Commented Aug 1, 2014 at 17:51
  • What does the program do? If it's just printing data the command prompt is uses for output won't stick around after you double click it Commented Aug 1, 2014 at 17:55
  • It's a packet sniffing utility (using scapy.sniff()) that sends results using a twisted server. The sniffing filter selects the correct packets when run from the command line, but not when opened in the python command line tool. Commented Aug 1, 2014 at 18:02

1 Answer 1

1

Your problem is probably that you expect the little window that pops up when you run the program by double-clicking to stay there. You can keep it there by adding this to the end of your script:

raw_input("Press any key to continue...")
Sign up to request clarification or add additional context in comments.

4 Comments

Sorry, I should have specified what type of program it was. It uses scapy.sniff() which blocks and keeps the window alive. The difference is that the cmd version filters the right packets and the python command line version doesn't filter the correct packets.
Sometimes people (accidentally) set one version of Python to run on the CLI (in their path), but set another version to run when double-clicking python files. (The same thing can happen with packages, too). Check and make sure this isn't the case.
That gave me hope, as many of my VMs have multiple versions of python, but sadly this one has only 2.6.3 (required by scapy).
Then the only thing left that could be the problem is the directory python is ran from. That's the only thing that's (usually) different between CLI Python and double-clicking Python.

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.