How to run a python file as an admin?

Asked

Viewed 1,073 times

4

I’m trying to run a python file, but it asks to be run as admin as q do this?

2 answers

4

Windows

Run Command Prompt or Powershell with Run as Administrator option.

Run the command normally:

> python seu_script.py

Linux and Mac

In Terminal, use:

> sudo python seu_script.py

0

that’s right

python python_script.py

in windows

and

su
bash
chmod +x python_scrypt.py
sudo python python_script.py

in linux/osx

to install python modules (let’s assume, google’s tensorflow, for example), you will need to use as commands:

pip install myPythonExtenson 

this for python 2

for python 3 should run

pip3 install myPythonExtension
  • The difference between your reply and previously given is only indicative of how to install modules via pip. Since it is not part of the scope of the question, you can convert this answer into a comment of the other answer if you judge even if this information is pertinent to the topic.

  • I would do it gladly, but I don’t have a sufficient score yet, to put comments

  • for hchmar with "python" in front, you do not need "chmod + x" - chmod is for when you want to run the command directly by its name.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.