Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SubprocessError: Exception occurred in preexec_fn #139

Open
10 tasks
mikechen66 opened this issue Jun 9, 2024 · 1 comment
Open
10 tasks

SubprocessError: Exception occurred in preexec_fn #139

mikechen66 opened this issue Jun 9, 2024 · 1 comment

Comments

@mikechen66
Copy link

mikechen66 commented Jun 9, 2024

Information

The problem arises in chapter:

  • Introduction
  • Text Classification
  • Transformer Anatomy
  • Multilingual Named Entity Recognition
  • Text Generation
  • Summarization
  • [ *] Question Answering
  • Making Transformers Efficient in Production
  • Dealing with Few to No Labels
  • Training Transformers from Scratch
  • Future Directions

Describe the bug

[chown Operation not permitted]

chown: changing ownership of 'elasticsearch-7.9.2/NOTICE.txt': Operation not permitted
chown: changing ownership of 'elasticsearch-7.9.2/config/users_roles': Operation not permitted
chown: changing ownership of 'elasticsearch-7.9.2/config/log4j2.properties': Operation not permitted

File ~/miniconda3/envs/torch/lib/python3.10/subprocess.py:1864, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session)
1862 err_msg = os.strerror(errno_num)
1863 raise child_exception_type(errno_num, err_msg, err_filename)
-> 1864 raise child_exception_type(err_msg)

To Reproduce

Steps to reproduce the behavior:

  1. !chown -R daemon:daemon elasticsearch-7.9.2
  2. es_server = Popen(args=['elasticsearch-7.9.2/bin/elasticsearch'],
    stdout=PIPE, stderr=STDOUT, preexec_fn=lambda: os.setuid(1))

Expected behavior

@mikechen66
Copy link
Author

The following attempts failed

1. Add password

!sudo -S apt-get install blah /home/mike/Documents/transformer-notebooks/mypassword

It propmts a box for authenticating a password. After input the password,it allows it to go through the step.

!sudo chown -R daemon:daemon elasticsearch-7.9.2

It reminds me of inputing password. However, there is no a prompted box for filling the password again.

2. Try getpass function

The following command also is not useful.

import getpass
import os

password = getpass.getpass()
command = "sudo -S apt-get update" #can be any command but don't forget -S as it enables input from stdin
os.system('echo %s | %s' % (password, command))

Reference:

https://stackoverflow.com/questions/44996933/using-sudo-inside-jupyter-notebooks-cell
https://stackoverflow.com/questions/77991709/exception-handling-for-subprocess-run
https://askubuntu.com/questions/1380103/chown-operation-not-permitted
jupyterhub/jupyterhub#1527
#139
https://jupyterhub.readthedocs.io/en/stable/howto/configuration/config-sudo.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant