Linked Questions
68 questions linked to/from What alternative is there to execfile in Python 3? / How to include a Python file?
72
votes
4
answers
118k
views
Alternative to execfile in Python 3? [duplicate]
Python 2 had the builtin function execfile, which was removed in Python 3.0. This question discusses alternatives for Python 3.0, but some considerable changes have been made since Python 3.0.
What ...
3
votes
0
answers
14k
views
The Python 3.3 equivalent of 'execfile' [duplicate]
I need to find out how to open my .py files after writing them in Notepad++. I find the interface more useful than the Python window.
In a tutorial I was following along with the guy uses
execfile(...
1
vote
0
answers
581
views
'execfile' not defined in apache2 config [duplicate]
I want to deploy two different Django apps in the same host with the different virtual environment (python2.7 and python 3.6). I had followed the tutorial https://www.thecodeship.com/deployment/deploy-...
0
votes
0
answers
52
views
IPython evaluate file from local directory [duplicate]
I'm wondering how I would go about evaluating the definitions of a python file in the directory my IPython REPL is running in. This would seem like a great workflow to be able to test the functions I ...
369
votes
27
answers
369k
views
How to execute a Python script from the Django shell?
I need to execute a Python script from the Django shell. I tried:
./manage.py shell << my_script.py
But it didn't work. It was just waiting for me to write something.
402
votes
12
answers
882k
views
How to execute a file within the Python interpreter?
I'm trying to execute a file with Python commands from within the interpreter.
I'm trying to use variables and settings from that file, not to invoke a separate process.
436
votes
8
answers
1.1m
views
How can I make one python file run another? [duplicate]
How can I make one python file to run another?
For example I have two .py files. I want one file to be run, and then have it run the other .py file.
212
votes
22
answers
162k
views
How can I get the version defined in setup.py (setuptools) in my package?
How could I get the version defined in setup.py from my package (for --version, or other purposes)?
134
votes
15
answers
423k
views
How to run a python script from IDLE interactive shell?
How do I run a python script from within the IDLE interactive shell?
The following throws an error:
>>> python helloworld.py
SyntaxError: invalid syntax
144
votes
12
answers
221k
views
Activate a virtualenv with a Python script
I want to activate a virtualenv instance from a Python script.
I know it's quite easy to do, but all the examples I've seen use it to run commands within the env and then close the subprocess.
I ...
79
votes
6
answers
104k
views
Is there a possibility to execute a Python script while being in interactive mode
Normally you can execute a Python script for example: python myscript.py, but if you are in the interactive mode, how is it possible to execute a Python script on the filesystem?
>>> exec(...
49
votes
12
answers
137k
views
Copying and pasting code directly into the Python interpreter
There is a snippet of code that I would like to copy and paste into my Python interpreter. Unfortunately due to Python's sensitivity to whitespace it is not straightforward to copy and paste it a way ...
54
votes
8
answers
91k
views
how to "source" file into python script
I have a text file /etc/default/foo which contains one line:
FOO="/path/to/foo"
In my python script, I need to reference the variable FOO.
What is the simplest way to "source" the file /etc/default/...
51
votes
2
answers
40k
views
NameError: global name 'execfile' is not defined trying to run an app on Google App Engine Launcher
I get this error in windows, I have both 3.2 and 2.7 versions of python. How can I fix this?
26
votes
7
answers
16k
views
how to modularize django settings.py?
When you install a new django application, you have to add/modify your settings.py module.
For a project I'm trying to make that module a python subpackage and create a module for each application:
...