Linked Questions
31 questions linked to/from How to execute a file within the Python interpreter?
11 votes
2 answers
18k views
running python script in interactive python prompt and keep the variables? [duplicate]
I understand from How do I run a Python program? that in command prompt i can use C:\python>python first.py , to run first.py. But, is it possible, that after i entered the interactive python ...
-1 votes
1 answer
1k views
Get Lua table in python [duplicate]
I have file tbl.lua with lua table: SpeedFM={} SpeedFM[20000101]=0.77566 SpeedFM[20000102]=0.77569 SpeedFM[20000103]=0.7757 SpeedFM[20000104]=0.77569 Using lua I just make dofile('tbl.lua') and get ...
0 votes
0 answers
18 views
Feeding an input definitions of variables to a Python script [duplicate]
I have my Python code to run a simulation stored in a file called script. This script takes a lot of input parameters that will be used to run the simulation. Now, I want to separate the definitions ...
461 votes
12 answers
416k views
What alternative is there to execfile in Python 3? / How to include a Python file?
It seems like in Python 3 they've removed all of the easy ways to quickly load a script, by removing execfile(). What alternative is there to include a Python file in another one, and execute it?
80 votes
13 answers
215k views
Execute a file with arguments in Python shell
I would like to run a command in Python Shell to execute a file with an argument. For example: execfile("abc.py") but how to add 2 arguments?
14 votes
2 answers
41k views
spawning process from python
im spawning a script that runs for a long time from a web app like this: os.spawnle(os.P_NOWAIT, "../bin/producenotify.py", "producenotify.py", "xx",os.environ) the script is spawned successfully and ...
5 votes
1 answer
16k views
How can I import a .pyc compiled python file and use it
Im trying to figure out how to include a .pyc file in a python script. For example my script is called: myscript.py and the script I would like to include is called: included_script.pyc So, do I ...
4 votes
3 answers
68k views
module import: NameError: name is not defined
How do I define the function in the importer so that it is visible inside imported? I tried this importer.py is def build(): print "building" build() import imported Whereby, imported.py is ...
-1 votes
2 answers
6k views
Why am I getting a syntax error whenever I try to run VS code python terminal? [duplicate]
Whenever I try to run the VS code python terminal, I get the following error: File "<stdin>", line 1 & C:/Users/tawsi/AppData/Local/Microsoft/WindowsApps/python.exe c:/Users/...
1 vote
3 answers
7k views
tkinter - ask the user for files directory and then run a script
I'm new to Python and I really need help on this, I've been looking everywhere but i can't find an answer. I created a script that compares data from 2 Excels files and write a report in a new file. ...
3 votes
3 answers
5k views
File "<string>" traceback with line preview
I'm making a couple of functions via exec, that could possibly error. However when Python errors out it doesn't display the line that the error occurred on. For example using: fn_str = '''\ def fn():...
-1 votes
6 answers
1k views
Executing python code
I am starting fresh with python and trying to execute a code from the python command window. I wrote a file on Desktop\practice\new.py and lunched the python command window. when I type C:\users\...
3 votes
4 answers
475 views
Interactive Python like Interactive Ruby?
I'm trying to load a ".py" file in Python like I did with a ".rb" file in interactive Ruby. This file runs a code which asks for a user's name, and then prints "Hello (user's name), welcome!". I have ...
5 votes
1 answer
3k views
Automatically run another script after i run main code in PyCharm
I have been looking for a feature where PyCharm notifies me that a script has finished running in the console after each run. At present, I have to add print('done') after each code. I got smarter so ...
1 vote
2 answers
2k views
Invalid Syntax Error when running Python script on PythonAnywhere
I'm trying to run the Python script that I wrote for scraping a particular website, and then I need to get notified with an email when the price reaches a specific number, for that matter I used ...