How do I get a python program to run instead of opening in Notepad?

2024/10/2 6:43:55

I am having some trouble with opening a .py file. I have a program that calls this .py file (i.e. pathname/example.py file.txt), but instead of running the python program, it opens it in Notepad. How to I get it to run?

The program itself takes in a file, and creates an output that is more readable.

Edit: The operating system is Windows 7. And the file that is calling the python is a .bat file.

Edit 2: It looks like I had to reinstall python for some reason... but it looks like it is finally working. Why reinstalling never comes to mind in the first place... And then I had to change how the file extention was opened. Thanks guys

Answer

This happened because most probably you have set notepad as the default program to open a .py file. Go to default programs app in windows. Select choose app by extension. Here search for .py files. Change the option from notepad to python. This should solve your problem.

https://en.xdnf.cn/q/70887.html

Related Q&A

How to find a keys value from a list of dictionaries?

How do I get a given keys value from a list of dictionaries? mylist = [{powerpoint_color: blue,client_name: Sport Parents (Regrouped)},{sort_order: ascending,chart_layout: 1,chart_type: bar} ]The numb…

Wandering star - codeabbey task

Im trying to solve this problem and Im not sure what to do next. Link to the problem Problem statement: Suppose that some preliminary image preprocessing was already done and you have data in form of …

Find delimiter in txt to convert to csv using Python

I have to convert some txt files to csv (and make some operation during the conversion).I use csv.Sniffer() class to detect wich delimiter is used in the txt This codewith open(filename_input, r) as f1…

Assert mocked function called with json string in python

Writing some unit tests in python and using MagicMock to mock out a method that accepts a JSON string as input. In my unit test, I want to assert that it is called with given arguments, however I run i…

read certificate(.crt) and key(.key) file in python

So im using the JIRA-Python module to connect to my companys instance on JIRA and it requires me to pass the certificate and key for this. However using the OpenSSL module,im unable to read my local ce…

Admin FileField current url incorrect

In the Django admin, wherever I have a FileField, there is a "currently" box on the edit page, with a hyperlink to the current file. However, this link is appended to the current page url, an…

Difference between generator expression and generator function

Is there any difference — performance or otherwise — between generator expressions and generator functions?In [1]: def f():...: yield from range(4)...:In [2]: def g():...: return (i for i in…

Django performance testing suite thatll report on metrics (db queries etc.)

I have a complex Django web application that has many person-years of work put into it. It might need optimisation sometime. There are several common operation/flows that I could script with (say) djan…

dev_appserver.py Opens a Text File, Does Not Deploy

It works fine on my other computer, but after setting up Google App Engine and creating the main.py and app.yaml files, I run dev_appserver.py app.yaml in Windows command prompt and instead of deployin…

How to pass a list from a view to template in django

I am trying pass to list from a view to template in Django.In my file wiew.py I define the view named hour # This Python file uses the following encoding: utf-8from django.shortcuts import render from …