sudo

Cannot run Python script using sudo

Cannot run Python script using sudo Question: I have a simple script which is using signalr-client-py as an external module. from requests import Session from signalr import Connection import threading When I try to run my script using the sudo python myScriptName.py I get an error: Traceback (most recent call last): File “buttonEventDetectSample.py”, line 3, …

Total answers: 3

What does sudo -H do?

What does sudo -H do? Question: After trying to install virtualenv with pip $ pip install virtualenv I got a permission denied error IOError: [Errno 13] Permission denied: ‘/Library/Python/2.7/site-packages/virtualenv.py’ So I used sudo to install virtualenv $ sudo pip install virtualenv But then a warning showed up: The directory ‘/Users/petertao/Library/Caches/pip/http’ or its parent directory is …

Total answers: 2

error when "sudo pip" on an AWS ec2 instance

error when "sudo pip" on an AWS ec2 instance Question: I am trying to run a small python code (which requries pytz and some other packages) on a aws ec2 instance. When I tried to install pytz, I got some errors: [ec2-user@ip-172-31-28-178 ~]$ pip install pytz Collecting pytz Using cached pytz-2016.7-py2.py3-none-any.whl Installing collected packages: pytz …

Total answers: 3

How to install a module for all users with pip on linux?

How to install a module for all users with pip on linux? Question: How to install a package in the standard python environment i.e. /usr/local/lib/python2.7/dist-packages using pip and make this new package available for all the users without using virtualenv? By using the following, the package is installed with root permissions only: $ sudo pip …

Total answers: 4

What are the risks of running 'sudo pip'?

What are the risks of running 'sudo pip'? Question: Occasionally I run into comments or responses that state emphatically that running pip under sudo is "wrong" or "bad", but there are cases (including the way I have a bunch of tools set up) where it is either much simpler, or even necessary to run it …

Total answers: 5

Getting "Permission Denied" when running pip as root on my Mac

Getting "Permission Denied" when running pip as root on my Mac Question: I’ve started to use my Mac to install Python packages in the same way I do with my Windows PC at work; however on my Mac I’ve come across frequent permission denied errors while writing to log files or site-packages. Therefore I thought …

Total answers: 6

Change to sudo user within a python script

Change to sudo user within a python script Question: I have a problem. I am writing a piece of software, which is required to perform an operation which requires the user to be in sudo mode. running ‘sudo python filename.py’ isn’t an option, which leads me to my question. Is there a way of changing …

Total answers: 9

Can I prevent fabric from prompting me for a sudo password?

Can I prevent fabric from prompting me for a sudo password? Question: I am using Fabric to run commands on a remote server. The user with which I connect on that server has some sudo privileges, and does not require a password to use these privileges. When SSH’ing into the server, I can run sudo …

Total answers: 8

Unable to install Python without sudo access

Unable to install Python without sudo access Question: I extracted, configured and used make for the installation package in my server. However, I could not use make install. I get the error [~/wepapps/python/Python-2.6.1]# make install /usr/bin/install -c python /usr/local/bin/python2.6 /usr/bin/install: cannot create regular file `/usr/local/bin/python2.6′: Permission denied make: *** [altbininstall] Error 1 I run the …

Total answers: 4

running a command as a super user from a python script

running a command as a super user from a python script Question: So I’m trying to get a process to be run as a super user from within a python script using subprocess. In the ipython shell something like proc = subprocess.Popen(‘sudo apach2ctl restart’, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) works fine, but as soon as I …

Total answers: 9