dp7
dp7

Reputation: 6749

Flask PermissionError: [Errno 13] Permission denied

I am trying to run a Flask application using /opt/mount1/python35/bin/python3.5 notification.py and I am getting the following error:

WARNING:tensorflow:From /opt/mount1/python35/lib/python3.5/site-packages/tensorflow/python/framework/op_def_library.py:263: colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.
Instructions for updating:
Colocations handled automatically by placer.
 * Serving Flask app "notification" (lazy loading)
 * Environment: production
   WARNING: Do not use the development server in a production environment.
   Use a production WSGI server instead.
 * Debug mode: on
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
 * Restarting with stat
Traceback (most recent call last):
  File "notification.py", line 19, in <module>
    app.run(debug=True)
  File "/opt/mount1/python35/lib/python3.5/site-packages/flask/app.py", line 943, in run
    run_simple(host, port, self, **options)
  File "/opt/mount1/python35/lib/python3.5/site-packages/werkzeug/serving.py", line 988, in run_simple
    run_with_reloader(inner, extra_files, reloader_interval, reloader_type)
  File "/opt/mount1/python35/lib/python3.5/site-packages/werkzeug/_reloader.py", line 332, in run_with_reloader
    sys.exit(reloader.restart_with_reloader())
  File "/opt/mount1/python35/lib/python3.5/site-packages/werkzeug/_reloader.py", line 176, in restart_with_reloader
    exit_code = subprocess.call(args, env=new_environ, close_fds=False)
  File "/opt/mount1/python35/lib/python3.5/subprocess.py", line 247, in call
    with Popen(*popenargs, **kwargs) as p:
  File "/opt/mount1/python35/lib/python3.5/subprocess.py", line 676, in __init__
    restore_signals, start_new_session)
  File "/opt/mount1/python35/lib/python3.5/subprocess.py", line 1289, in _execute_child
    raise child_exception_type(errno_num, err_msg)
PermissionError: [Errno 13] Permission denied

I have given recursive 777 permission to the flask application folder.

From the above stack trace, I am not sure what is going wrong.

Any help will be appreciated. Thanks!


Updates

I tried to run the Flask app using the core python of CentOS 7.6 i.e Python 2.7 and it worked!!

I am not sure why it is not working for a python version 3.5.6 which has been installed from its RPM to the path /opt/mount1/python35.

Upvotes: 3

Views: 9769

Answers (2)

dp7
dp7

Reputation: 6749

Since I had installed the Python 3.5 separately in a different path, I had to place the following shebang at the top of my file to fix the issue:

#!/opt/mount1/python35/bin/python3.5

Upvotes: 1

Rachel Gallen
Rachel Gallen

Reputation: 28573

Error 13 (your permissions error) is usually resolved by changing your port number. TCP/IP port numbers below 1024 are registered or 'privileged' port numbers - users are not allowed to run servers on them. My guess from the first warning message shown (regarding the server in a production environment) is that you are running your application on a low port number (probably 80), but you if you run it on a different port number, say 4000 or something (over 1024), you will avoid this error.

You may find this link helpful

excerpt:

import socket

HOST = '127.0.0.1'  # Standard loopback interface address (localhost)
PORT = 65432        # Port to listen on (non-privileged ports are > 1023)

Upvotes: 8

Related Questions