I had original made a Stack Overflow post.
I've this command causing errors further down my Jupyter Notebook (detailed in SO post):
! chown -R daemon:daemon elasticsearch-7.9.2
Giving many of these outputs:
chown: changing ownership of ‘elasticsearch-7.9.2/NOTICE.txt’: Operation not permitted
...
---------------------------------------------------------------------------
SubprocessError Traceback (most recent call last)
<ipython-input-25-5f043305a2ca> in <module>
8 es_server = Popen(['elasticsearch-7.9.2/bin/elasticsearch'],
9 stdout=PIPE, stderr=STDOUT,
---> 10 preexec_fn=lambda: os.setuid(1) # as daemon
11 )
12 # wait until ES has started
~/anaconda3/envs/mxnet_latest_p37/lib/python3.7/subprocess.py in init(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, encoding, errors, text)
798 c2pread, c2pwrite,
799 errread, errwrite,
--> 800 restore_signals, start_new_session)
801 except:
802 # Cleanup if the child failed starting.
~/anaconda3/envs/mxnet_latest_p37/lib/python3.7/subprocess.py in _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, start_new_session)
1550 err_msg += ': ' + repr(err_filename)
1551 raise child_exception_type(errno_num, err_msg, err_filename)
-> 1552 raise child_exception_type(err_msg)
1553
1554
SubprocessError: Exception occurred in preexec_fn.
SubprocessError Traceback (most recent call last)
<ipython-input-25-5f043305a2ca> in <module>
8 es_server = Popen(['elasticsearch-7.9.2/bin/elasticsearch'],
9 stdout=PIPE, stderr=STDOUT,
---> 10 preexec_fn=lambda: os.setuid(1) # as daemon
11 )
12 # wait until ES has started
~/anaconda3/envs/mxnet_latest_p37/lib/python3.7/subprocess.py in init(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, encoding, errors, text)
798 c2pread, c2pwrite,
799 errread, errwrite,
--> 800 restore_signals, start_new_session)
801 except:
802 # Cleanup if the child failed starting.
~/anaconda3/envs/mxnet_latest_p37/lib/python3.7/subprocess.py in _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, start_new_session)
1550 err_msg += ': ' + repr(err_filename)
1551 raise child_exception_type(errno_num, err_msg, err_filename)
-> 1552 raise child_exception_type(err_msg)
1553
1554
SubprocessError: Exception occurred in preexec_fn.
Appending sudo seems to partially fix my issue as Operation not permitted statements no longer appear:
! sudo chown -R daemon:daemon elasticsearch-7.9.2
However, the SubprocessError traceback remains.
How can I give Python or the kernel or AWS SageMaker root permissions?
os.setuid(), and that's the place where the error is indicated. To change UID, the code must be running as root. Is it running with root permissions? BTW. I don't see how changing the immutable attribute (chattr -i) could help you in this. – raj Dec 09 '21 at 14:56chattr -ias a solution from post. – StressedBoi69420 Dec 09 '21 at 15:05