I am attempting to run a python3 script on boot with my raspberry. The python script contains a subprocess call that is giving me problems. I suspect that the problem has to do with the PATH of the streamlink call, but I am not managing to solve it.
the script:
#!/usr/bin/env python3
import subprocess
def streamlistener(streamname):
try:
print('Listening to stream: ',streamname)
grepOut = subprocess.check_output(['streamlink','-p','omxplayer','-a','--timeout 20', '--player-fifo','--retry-strea$
print(grepOut.decode())
streamlistener(streamname)
except subprocess.CalledProcessError as e:
print("ERRORS: " , e.output.decode())
streamlistener(streamname)
streamlistener('STREAMNAME')
the crontab (same results without the sleep command):
#reboot sleep 60 && sudo python3 /home/pi/Desktop/stream.py 2>&1 | logger -p user.debug -t 'stream'
The error message I get:
Jun 28 17:40:39 raspberrypi stream: Traceback (most recent call last):
Jun 28 17:40:39 raspberrypi stream: File "/home/pi/Desktop/stream.py", line 26, in <module>
Jun 28 17:40:39 raspberrypi stream: streamlistener('northernstreaming')
Jun 28 17:40:39 raspberrypi stream: File "/home/pi/Desktop/stream.py", line 19, in streamlistener
Jun 28 17:40:39 raspberrypi stream: grepOut = subprocess.check_output(['streamlink','-p','omxplayer','-a','--timeout 20', '--pla$
Jun 28 17:40:39 raspberrypi stream: File "/usr/lib/python3.7/subprocess.py", line 395, in check_output
Jun 28 17:40:39 raspberrypi stream: **kwargs).stdout
Jun 28 17:40:39 raspberrypi stream: File "/usr/lib/python3.7/subprocess.py", line 472, in run
Jun 28 17:40:39 raspberrypi stream: with Popen(*popenargs, **kwargs) as process:
Jun 28 17:40:39 raspberrypi stream: File "/usr/lib/python3.7/subprocess.py", line 775, in __init__
Jun 28 17:40:39 raspberrypi stream: restore_signals, start_new_session)
Jun 28 17:40:39 raspberrypi stream: File "/usr/lib/python3.7/subprocess.py", line 1522, in _execute_child
Jun 28 17:40:39 raspberrypi stream: raise child_exception_type(errno_num, err_msg, err_filename)
Jun 28 17:40:39 raspberrypi stream: FileNotFoundError: [Errno 2] No such file or directory: 'streamlink': 'streamlink'
The problem had to do with the PATH pip3 used to install streamlink and not with the subprocess.check_output call, setting the paths properly in both bashrc and at the start of the crontab worked.
Setting path in bashrc:https://linuxize.com/post/how-to-add-directory-to-path-in-linux/
Setting path in cron: https://unix.stackexchange.com/questions/148133/how-to-set-crontab-path-variable
Related
Getting this error if I call an API which publishes message to pub sub in background.
Application have same pub sub code somewhere else in another script as well and that works fine. This addition is breaking.
2022-11-01 22:37:01.168 MDT
Current thread 0x00003ecdf3e00700 (most recent call first):
2022-11-01 22:37:01.169 MDT
File "/usr/local/lib/python3.7/site-packages/grpc/_channel.py", line 933 in _blocking
2022-11-01 22:37:01.169 MDT
File "/usr/local/lib/python3.7/site-packages/grpc/_channel.py", line 945 in __call__
2022-11-01 22:37:01.169 MDT
File "/usr/local/lib/python3.7/site-packages/google/api_core/grpc_helpers.py", line 72 in error_remapped_callable
2022-11-01 22:37:01.169 MDT
File "/usr/local/lib/python3.7/site-packages/google/api_core/timeout.py", line 99 in func_with_timeout
2022-11-01 22:37:01.170 MDT
File "/usr/local/lib/python3.7/site-packages/google/api_core/retry.py", line 190 in retry_target
2022-11-01 22:37:01.170 MDT
File "/usr/local/lib/python3.7/site-packages/google/api_core/retry.py", line 288 in retry_wrapped_func
2022-11-01 22:37:01.170 MDT
File "/usr/local/lib/python3.7/site-packages/google/api_core/gapic_v1/method.py", line 154 in __call__
2022-11-01 22:37:01.170 MDT
File "/usr/local/lib/python3.7/site-packages/google/pubsub_v1/services/publisher/client.py", line 785 in publish
2022-11-01 22:37:01.171 MDT
File "/usr/local/lib/python3.7/site-packages/google/cloud/pubsub_v1/publisher/client.py", line 272 in _gapic_publish
2022-11-01 22:37:01.171 MDT
File "/usr/local/lib/python3.7/site-packages/google/cloud/pubsub_v1/publisher/_batch/thread.py", line 278 in _commit
2022-11-01 22:37:01.171 MDT
File "/usr/local/lib/python3.7/threading.py", line 870 in run
2022-11-01 22:37:01.171 MDT
File "/usr/local/lib/python3.7/threading.py", line 926 in _bootstrap_inner
2022-11-01 22:37:01.172 MDT
File "/usr/local/lib/python3.7/threading.py", line 890 in _bootstrap
2022-11-01 22:37:01.172 MDT
Thread 0x00003ecec975e740 (most recent call first):
2022-11-01 22:37:01.172 MDT
File "/usr/local/lib/python3.7/site-packages/gunicorn/workers/sync.py", line 36 in wait
2022-11-01 22:37:01.172 MDT
File "/usr/local/lib/python3.7/site-packages/gunicorn/workers/sync.py", line 84 in run_for_one
2022-11-01 22:37:01.172 MDT
File "/usr/local/lib/python3.7/site-packages/gunicorn/workers/sync.py", line 125 in run
2022-11-01 22:37:01.172 MDT
File "/usr/local/lib/python3.7/site-packages/gunicorn/workers/base.py", line 142 in init_process
2022-11-01 22:37:01.173 MDT
File "/usr/local/lib/python3.7/site-packages/gunicorn/arbiter.py", line 589 in spawn_worker
2022-11-01 22:37:01.173 MDT
File "/usr/local/lib/python3.7/site-packages/gunicorn/arbiter.py", line 622 in spawn_workers
2022-11-01 22:37:01.173 MDT
File "/usr/local/lib/python3.7/site-packages/gunicorn/arbiter.py", line 551 in manage_workers
2022-11-01 22:37:01.173 MDT
File "/usr/local/lib/python3.7/site-packages/gunicorn/arbiter.py", line 202 in run
2022-11-01 22:37:01.173 MDT
File "/usr/local/lib/python3.7/site-packages/gunicorn/app/base.py", line 72 in run
2022-11-01 22:37:01.174 MDT
File "/usr/local/lib/python3.7/site-packages/gunicorn/app/base.py", line 231 in run
2022-11-01 22:37:01.174 MDT
File "/usr/local/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 67 in run
2022-11-01 22:37:01.174 MDT
File "/usr/local/bin/gunicorn", line 8 in <module>
2022-11-01 22:37:01.174 MDT
Uncaught signal: 11, pid=42, tid=54, fault_addr=42.
2022-11-01 22:37:01.184 MDT
[2022-11-02 04:37:01 +0000] [2] [WARNING] Worker with pid 42 was terminated due to signal 11```
I installed libapache2-mod-wsgi-py3 but It seems good for python3.6. My problem is set mod-wsgi for use python3.9 because my app django has all modules installed for this version.
How can I do?
I attach error log
[Fri Oct 21 10:22:21.549718 2022] [wsgi:error] [pid 8227] mod_wsgi (pid=8227): Target WSGI script '/var/www/html/elastic_queries/python/djangosite/giustiziasite/giustiziasite/wsgi.py' cannot be loaded as Python module.
[Fri Oct 21 10:22:21.549795 2022] [wsgi:error] [pid 8227] mod_wsgi (pid=8227): Exception occurred processing WSGI script '/var/www/html/elastic_queries/python/djangosite/giustiziasite/giustiziasite/wsgi.py'.
[Fri Oct 21 10:22:21.550458 2022] [wsgi:error] [pid 8227] Traceback (most recent call last):
[Fri Oct 21 10:22:21.550517 2022] [wsgi:error] [pid 8227] File "/var/www/html/elastic_queries/python/djangosite/giustiziasite/giustiziasite/wsgi.py", line 18, in <module>
[Fri Oct 21 10:22:21.550522 2022] [wsgi:error] [pid 8227] application = StaticFilesHandler(get_wsgi_application())
[Fri Oct 21 10:22:21.550528 2022] [wsgi:error] [pid 8227] File "/usr/local/lib/python3.6/dist-packages/django/core/wsgi.py", line 12, in get_wsgi_application
[Fri Oct 21 10:22:21.550532 2022] [wsgi:error] [pid 8227] django.setup(set_prefix=False)
[Fri Oct 21 10:22:21.550537 2022] [wsgi:error] [pid 8227] File "/usr/local/lib/python3.6/dist-packages/django/__init__.py", line 24, in setup
[Fri Oct 21 10:22:21.550541 2022] [wsgi:error] [pid 8227] apps.populate(settings.INSTALLED_APPS)
[Fri Oct 21 10:22:21.550546 2022] [wsgi:error] [pid 8227] File "/usr/local/lib/python3.6/dist-packages/django/apps/registry.py", line 114, in populate
[Fri Oct 21 10:22:21.550550 2022] [wsgi:error] [pid 8227] app_config.import_models()
[Fri Oct 21 10:22:21.550555 2022] [wsgi:error] [pid 8227] File "/usr/local/lib/python3.6/dist-packages/django/apps/config.py", line 301, in import_models
[Fri Oct 21 10:22:21.550558 2022] [wsgi:error] [pid 8227] self.models_module = import_module(models_module_name)
[Fri Oct 21 10:22:21.550563 2022] [wsgi:error] [pid 8227] File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
[Fri Oct 21 10:22:21.550567 2022] [wsgi:error] [pid 8227] return _bootstrap._gcd_import(name[level:], package, level)
[Fri Oct 21 10:22:21.550572 2022] [wsgi:error] [pid 8227] File "<frozen importlib._bootstrap>", line 994, in _gcd_import
[Fri Oct 21 10:22:21.550577 2022] [wsgi:error] [pid 8227] File "<frozen importlib._bootstrap>", line 971, in _find_and_load
[Fri Oct 21 10:22:21.550583 2022] [wsgi:error] [pid 8227] File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
[Fri Oct 21 10:22:21.550588 2022] [wsgi:error] [pid 8227] File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
[Fri Oct 21 10:22:21.550594 2022] [wsgi:error] [pid 8227] File "<frozen importlib._bootstrap_external>", line 678, in exec_module
[Fri Oct 21 10:22:21.550599 2022] [wsgi:error] [pid 8227] File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
[Fri Oct 21 10:22:21.550605 2022] [wsgi:error] [pid 8227] File "/var/www/html/elastic_queries/python/djangosite/giustiziasite/pygiustizia/models/__init__.py", line 2, in <module>
[Fri Oct 21 10:22:21.550608 2022] [wsgi:error] [pid 8227] from pygiustizia.models.model_judgements import CivileDocument
[Fri Oct 21 10:22:21.550613 2022] [wsgi:error] [pid 8227] File "/var/www/html/elastic_queries/python/djangosite/giustiziasite/pygiustizia/models/model_judgements.py", line 1, in <module>
[Fri Oct 21 10:22:21.550617 2022] [wsgi:error] [pid 8227] from elasticsearch import Elasticsearch
[Fri Oct 21 10:22:21.550645 2022] [wsgi:error] [pid 8227] ModuleNotFoundError: No module named 'elasticsearch'
Python3 subprocess.Popen is failing to remove the file with "FileNotFoundError: [Errno 2] No such file or directory" error. But executing the command directly from the bash terminal deletes the file.
current folder content:
tmp]$ ll
total 16
-rw-rw-r--. 1 root root 688 Apr 29 09:28 t1.py
-rw-rw-r--. 1 root root 688 Apr 29 10:41 t2.py
-rw-rw-r--. 1 root root 1052 Apr 29 10:41 t3.py
-rw-rw-r--. 1 root root 364 Apr 29 10:45 t4.py
Python Code (t4.py):
1 import subprocess
2
3
4 def execute_shell_command(command_list):
5 data = subprocess.Popen(command_list, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
6 output = data.communicate()
7 return output
8
9
10 cmd = ["rm -rf ", "", "t2*"]
11 command = cmd[0] + cmd[1] + cmd[2]
12 prnt1 = "Executing command: " + command
13 print(f"{prnt1}")
14 out2 = execute_shell_command(command)
15
Output:
tmp]$ python3 t4.py
Executing command: rm -rf t2*
Traceback (most recent call last):
File "t4.py", line 14, in <module>
out2 = execute_shell_command(command)
File "t4.py", line 5, in execute_shell_command
data = subprocess.Popen(command_list, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
File "/usr/lib64/python3.6/subprocess.py", line 729, in __init__
restore_signals, start_new_session)
File "/usr/lib64/python3.6/subprocess.py", line 1364, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'rm -rf t2*': 'rm -rf t2*'
Below code worked:
1 import subprocess
2
3
4 def execute_shell_command(command_list):
5 data = subprocess.Popen(command_list, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
6 output = data.communicate()
7 return output
8
9
10 cmd = ["rm -rf t2*"]
11 command = cmd[0]
12 prnt1 = "Executing command: " + command
13 print(f"{prnt1}")
14 out2 = execute_shell_command(command)
15 print(f"output = {out2[0]}")
16 print(f"error = {out2[1]}")
Basically, write the command as it is and then add one argument shell=True in the subprocess.Popen.
I am using the Laradock in my Laravel project for dockerizing with Nginx, Postgres, and Pgadmin. All the containers are running well but the Pgadmin is unable to do so. Here is my error log,
pgadmin_1 | WARNING: Failed to set ACL on the directory containing the configuration database: [Errno 1] Operation not permitted: '/var/lib/pgadmin'
pgadmin_1 | Traceback (most recent call last):
pgadmin_1 | File "run_pgadmin.py", line 4, in <module>
pgadmin_1 | from pgAdmin4 import app
pgadmin_1 | File "/pgadmin4/pgAdmin4.py", line 92, in <module>
pgadmin_1 | app = create_app()
pgadmin_1 | File "/pgadmin4/pgadmin/__init__.py", line 241, in create_app
pgadmin_1 | create_app_data_directory(config)
pgadmin_1 | File "/pgadmin4/pgadmin/setup/data_directory.py", line 40, in create_app_data_directory
pgadmin_1 | _create_directory_if_not_exists(config.SESSION_DB_PATH)
pgadmin_1 | File "/pgadmin4/pgadmin/setup/data_directory.py", line 16, in _create_directory_if_not_exists
pgadmin_1 | os.mkdir(_path)
pgadmin_1 | PermissionError: [Errno 13] Permission denied: '/var/lib/pgadmin/sessions'
pgadmin_1 | sudo: setrlimit(RLIMIT_CORE): Operation not permitted
pgadmin_1 | [2020-06-07 11:48:43 +0000] [1] [INFO] Starting gunicorn 19.9.0
pgadmin_1 | [2020-06-07 11:48:43 +0000] [1] [INFO] Listening at: http://[::]:80 (1)
pgadmin_1 | [2020-06-07 11:48:43 +0000] [1] [INFO] Using worker: threads
pgadmin_1 | /usr/local/lib/python3.8/os.py:1023: RuntimeWarning: line buffering (buffering=1) isn't supported in binary mode, the default buffer size will be used
pgadmin_1 | return io.open(fd, *args, **kwargs)
pgadmin_1 | [2020-06-07 11:48:43 +0000] [83] [INFO] Booting worker with pid: 83
pgadmin_1 | [2020-06-07 11:48:44 +0000] [83] [ERROR] Exception in worker process
pgadmin_1 | Traceback (most recent call last):
pgadmin_1 | File "/usr/local/lib/python3.8/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
pgadmin_1 | worker.init_process()
pgadmin_1 | File "/usr/local/lib/python3.8/site-packages/gunicorn/workers/gthread.py", line 104, in init_process
pgadmin_1 | super(ThreadWorker, self).init_process()
pgadmin_1 | File "/usr/local/lib/python3.8/site-packages/gunicorn/workers/base.py", line 129, in init_process
pgadmin_1 | self.load_wsgi()
pgadmin_1 | File "/usr/local/lib/python3.8/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi
pgadmin_1 | self.wsgi = self.app.wsgi()
pgadmin_1 | File "/usr/local/lib/python3.8/site-packages/gunicorn/app/base.py", line 67, in wsgi
pgadmin_1 | self.callable = self.load()
pgadmin_1 | File "/usr/local/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 52, in load
pgadmin_1 | return self.load_wsgiapp()
pgadmin_1 | File "/usr/local/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
pgadmin_1 | return util.import_app(self.app_uri)
pgadmin_1 | File "/usr/local/lib/python3.8/site-packages/gunicorn/util.py", line 350, in import_app
pgadmin_1 | __import__(module)
pgadmin_1 | File "/pgadmin4/run_pgadmin.py", line 4, in <module>
pgadmin_1 | from pgAdmin4 import app
pgadmin_1 | File "/pgadmin4/pgAdmin4.py", line 92, in <module>
pgadmin_1 | app = create_app()
pgadmin_1 | File "/pgadmin4/pgadmin/__init__.py", line 241, in create_app
pgadmin_1 | create_app_data_directory(config)
pgadmin_1 | File "/pgadmin4/pgadmin/setup/data_directory.py", line 40, in create_app_data_directory
pgadmin_1 | _create_directory_if_not_exists(config.SESSION_DB_PATH)
pgadmin_1 | File "/pgadmin4/pgadmin/setup/data_directory.py", line 16, in _create_directory_if_not_exists
pgadmin_1 | os.mkdir(_path)
pgadmin_1 | PermissionError: [Errno 13] Permission denied: '/var/lib/pgadmin/sessions'
pgadmin_1 | [2020-06-07 11:48:44 +0000] [83] [INFO] Worker exiting (pid: 83)
pgadmin_1 | WARNING: Failed to set ACL on the directory containing the configuration database: [Errno 1] Operation not permitted: '/var/lib/pgadmin'
pgadmin_1 | /usr/local/lib/python3.8/os.py:1023: RuntimeWarning: line buffering (buffering=1) isn't supported in binary mode, the default buffer size will be used
pgadmin_1 | return io.open(fd, *args, **kwargs)
pgadmin_1 | [2020-06-07 11:48:44 +0000] [1] [INFO] Shutting down: Master
pgadmin_1 | [2020-06-07 11:48:44 +0000] [1] [INFO] Reason: Worker failed to boot.
I have tried many ways to solve this problem. Such as,
OSError: [Errno 13] Permission denied: '/var/lib/pgadmin'
https://www.pgadmin.org/docs/pgadmin4/latest/container_deployment.html
and some other github issues and their solutions. I also run the sudo chmod -R 777 ~/.laradock/data/pgadmin and sudo chmod -R 777 /var/lib/pgadmin command to get the permission but still the same error log. Can you guys help me on this? I think some others are also getting this error on their local machine.
Thanks 🙂
You may try this:
sudo chown -R 5050:5050 ~/.laradock/data/pgadmin
Then restart the container. Cause in the container with:
uid=5050(pgadmin) gid=5050(pgadmin)
and
drwx------ 4 pgadmin pgadmin 56 Jan 27 08:25 pgadmin
As others have noted above, I found that Permission denied: '/var/lib/pgadmin/sessions' in Docker speaks to the challenge on the persistent local folder not having the correct user permissions.
After running sudo chown -R 5050:5050 ~/.laradock/data/pgadmin and restarting the container, the below error is no longer in my log
PermissionError: [Errno 13] Permission denied:
A similar error happens when using Kubernetes and the pgadmin4 helm chart from https://github.com/rowanruseler/helm-charts.
The solution is to set:
VolumePermissions:
enabled: true
even when persistence is not enabled. In this way also the /var/lib/pgadmin folder in the container gets assigned of the correct permissions and the pgadmin4.db database can be created correctly.
Assuming you have folder with pgadmin4.db already defined on your git repo with an other user than pgadmin, you can do so:
postgres_interface:
image: dpage/pgadmin4
environment:
- PGADMIN_DEFAULT_EMAIL=user#domain.com
- PGADMIN_DEFAULT_PASSWORD=postgres
ports:
- "5050:80"
user: root
volumes:
- ./env/local/pgadmin/pgadmin4.db:/pgadmin4.db
entrypoint: /bin/sh -c "cp /pgadmin4.db /var/lib/pgadmin/pgadmin4.db && cd /pgadmin4 && /entrypoint.sh"
The only solution I can provide is to log in to the container with
docker-compose exec --user root pgadmin sh
and then
chmod 0777 /var/lib/pgadmin -R
probably it may be better to create your own dockerfile from dpage/pgadmin4 and run these commands in advance.
I got this shell script from a blog about how to equip git with gitosis.
But i got a "No such file or directory" error after running the script.
[git#209285 ~]$ sudo -H -u git gitosis-init < ~/id_rsa.pub
Traceback (most recent call last):
File "/usr/local/bin/gitosis-init", line 9, in <module>
load_entry_point('gitosis==0.2', 'console_scripts', 'gitosis-init')()
File "/usr/local/lib/python2.7/site-packages/gitosis-0.2-py2.7.egg/gitosis/app.py", line 24, in run
return app.main()
File "/usr/local/lib/python2.7/site-packages/gitosis-0.2-py2.7.egg/gitosis/app.py", line 38, in main
self.handle_args(parser, cfg, options, args)
File "/usr/local/lib/python2.7/site-packages/gitosis-0.2-py2.7.egg/gitosis/init.py", line 138, in handle_args
user=user,
File "/usr/local/lib/python2.7/site-packages/gitosis-0.2-py2.7.egg/gitosis/init.py", line 75, in init_admin_repository
template=resource_filename('gitosis.templates', 'admin')
File "/usr/local/lib/python2.7/site-packages/gitosis-0.2-py2.7.egg/gitosis/repository.py", line 63, in init
close_fds=True,
File "/usr/local/lib/python2.7/subprocess.py", line 522, in call
return Popen(*popenargs, **kwargs).wait()
File "/usr/local/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/usr/local/lib/python2.7/subprocess.py", line 1335, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
I am puzzled,as the man manual says that:
-H The -H (HOME) option sets the HOME environment variable to the homedir of the target user (root by default) as specified in passwd(5). By default, sudo
does not modify HOME (see set_home and always_set_home in sudoers(5)).
,which is cited from linux manual.
The -H option just sets the HOME environment variable to the homedir of the target user as specified in passwd.
However i specified "/home/git" as homedir for git user in my /etc/passwd file.
apache:x:48:48:Apache:/var/www:/sbin/nologin
git:x:100:101:git version control:/home/git:/bin/bash
duanduan:x:101:500::/home/duanduan:/bin/bash
But why i still got this message? or was incorrect my comprehension of the description in manual?
Append for comments:
And it seems like before with specifying a absolute path.Maybe, it's not the cause.
sudo -H -u git gitosis-init < /home/git/id_rsa.pub
Traceback (most recent call last):
File "/usr/local/bin/gitosis-init", line 9, in <module>
load_entry_point('gitosis==0.2', 'console_scripts', 'gitosis-init')()
File "/usr/local/lib/python2.7/site-packages/gitosis-0.2-py2.7.egg/gitosis/app.py", line 24, in run
return app.main()
File "/usr/local/lib/python2.7/site-packages/gitosis-0.2-py2.7.egg/gitosis/app.py", line 38, in main
self.handle_args(parser, cfg, options, args)
File "/usr/local/lib/python2.7/site-packages/gitosis-0.2-py2.7.egg/gitosis/init.py", line 138, in handle_args
user=user,
File "/usr/local/lib/python2.7/site-packages/gitosis-0.2-py2.7.egg/gitosis/init.py", line 75, in init_admin_repository
template=resource_filename('gitosis.templates', 'admin')
File "/usr/local/lib/python2.7/site-packages/gitosis-0.2-py2.7.egg/gitosis/repository.py", line 63, in init
close_fds=True,
File "/usr/local/lib/python2.7/subprocess.py", line 522, in call
return Popen(*popenargs, **kwargs).wait()
File "/usr/local/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/usr/local/lib/python2.7/subprocess.py", line 1335, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
I guess it is because ~ is expanded by bash before transferring to sudo as a argument, why not try to specify a absolute path for you public key file?