Tasos Tasos
Tasos Tasos

Reputation: 1

How to make Windows execute my Python script files when I click them

I have made a Python program that uses output.to_csv('results.csv'). When I run it in Spyder it creates that CSV file. But when I double click on it nothing happens. Cmd appears and closes but nothing on the folder, no results.csv.

What am I missing? What more do I have to do?

Upvotes: 0

Views: 3570

Answers (3)

Tasos Tasos
Tasos Tasos

Reputation: 1

Ok i guess windows is not recommended at all for this type of tasks. I mean running something simple as create such file is like trying to kill the Lernaean Hydra. What i did is i just runned it with anaconda prompt and it worked sweet! Thanks for help. Thanks to all!

PS: I'm seriously considering changing to Linux after this

For anyone having the same problem, but have anaconda installed. 1) Open Anaconda Prompt, 2) use cd (1 space) then adress of the folder which contains your py program (eg. cd C:\Users\Bernie\Desktop\tasos) and hit enter, 3) on the next line that appears type: python program_name.py, 4)Hit enter, 5)success!

Upvotes: 0

AksLolCoding
AksLolCoding

Reputation: 157

If the .csv file really exists, you should be able to go to your File Explorer and find the file at the top of the "Quick Access" section. Right-click the file and hover over "Open With >". Then select Notepad and a notepad will open up showing your results.

If you do not see the file, then try running your program on the command prompt (for Windows):

  • Press the windows key and type "cmd" in the search bar.
  • Choose "Command Prompt"
  • Go to the dir of your program using the cd command
  • Type python <program name>.py
  • If there are no errors, follow the steps in the first paragraph.

Upvotes: 0

Dallan
Dallan

Reputation: 516

Run the program from the command line itself instead of double-clicking the .py file.

I assume you are on Windows since you mention CMD. First, cd into the directory containing your program. Then, run python <program>.py or python3 <program>.py depending on your installation.

This time, you will see any output or error messages that appear in CMD without it immediately closing.

Upvotes: 1

Related Questions