Home > python > OSError: [Errno 8] Exec format error

OSError: [Errno 8] Exec format error

Problem:
$ python3 run.py
* Serving Flask app "petsrus.petsrus" (lazy loading)
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: on
* Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
* Restarting with stat
Traceback (most recent call last):
File "run.py", line 4, in
app.run(host="0.0.0.0", port=5000)
File "/home/vagrant/env/lib/python3.4/site-packages/flask/app.py", line 944, in run
run_simple(host, port, self, **options)
File "/home/vagrant/env/lib/python3.4/site-packages/werkzeug/serving.py", line 1007, in run_simple
run_with_reloader(inner, extra_files, reloader_interval, reloader_type)
File "/home/vagrant/env/lib/python3.4/site-packages/werkzeug/_reloader.py", line 332, in run_with_reloader
sys.exit(reloader.restart_with_reloader())
File "/home/vagrant/env/lib/python3.4/site-packages/werkzeug/_reloader.py", line 176, in restart_with_reloader
exit_code = subprocess.call(args, env=new_environ, close_fds=False)
File "/usr/lib/python3.4/subprocess.py", line 537, in call
with Popen(*popenargs, **kwargs) as p:
File "/usr/lib/python3.4/subprocess.py", line 859, in __init__
restore_signals, start_new_session)
File "/usr/lib/python3.4/subprocess.py", line 1457, in _execute_child
raise child_exception_type(errno_num, err_msg)
OSError: [Errno 8] Exec format error


Solution:

Added #!/usr/bin/env python to the file

#!/usr/bin/env python
from myapp import app

if __name__ == "__main__":
app.run(host="0.0.0.0", port=5000)


Source:

https://stackoverflow.com/questions/27606653/oserror-errno-8-exec-format-error

Categories: python
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: