I am trying to build a script in Django that generates a report based on user input.
myscript.py
def run():
# analyze some data
user_input = input('Enter a value:')
# do secondary analysis based on input value
When I execute this script with python manage.py runscript myscript, it works until input() is called. "Enter a value:" is printed to the console, but instead of waiting for the user to enter a value, the program terminates with EOFError: EOF when reading a line. What is going on here?
Note: Passing arguments to the script with --script-args is not an acceptable workaround because the input value must be determined by the user after the initial data analysis.
Edit: Additional Diagnostic Information
Python 3.9.7
Django 3.2.12
Traceback (most recent call last):
File "/code/manage.py", line 22, in <module>
main()
File "/code/manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "/opt/conda/envs/docker-webdev-env/lib/python3.9/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
utility.execute()
File "/opt/conda/envs/docker-webdev-env/lib/python3.9/site-packages/django/core/management/__init__.py", line 413, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/opt/conda/envs/docker-webdev-env/lib/python3.9/site-packages/django_extensions/management/email_notifications.py", line 65, in run_from_argv
super().run_from_argv(argv)
File "/opt/conda/envs/docker-webdev-env/lib/python3.9/site-packages/django/core/management/base.py", line 354, in run_from_argv
self.execute(*args, **cmd_options)
File "/opt/conda/envs/docker-webdev-env/lib/python3.9/site-packages/django_extensions/management/email_notifications.py", line 77, in execute
super().execute(*args, **options)
File "/opt/conda/envs/docker-webdev-env/lib/python3.9/site-packages/django/core/management/base.py", line 398, in execute
output = self.handle(*args, **options)
File "/opt/conda/envs/docker-webdev-env/lib/python3.9/site-packages/django_extensions/management/utils.py", line 62, in inner
ret = func(self, *args, **kwargs)
File "/opt/conda/envs/docker-webdev-env/lib/python3.9/site-packages/django_extensions/management/commands/runscript.py", line 283, in handle
run_script(script_mod, *script_args)
File "/opt/conda/envs/docker-webdev-env/lib/python3.9/site-packages/django_extensions/management/commands/runscript.py", line 161, in run_script
exit_code = mod.run(*script_args)
File "/code/scripts/myscript.py", line 3, in run
user_input = input('Enter a value:')
EOFError: EOF when reading a line