Python Forum

Full Version: sudo apt Not Working
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Not sure this is the right place for this problem but it's where I thought was best. I'm relatively new to Python but did some programming in C+ many years ago.

Running Python 3.6.2 on Windows 10.

When I run "sudo apt-get upate" I get a syntax error.

Python 3.6.2 (v3.6.2:5fd33b5, Jul  8 2017, 04:14:34) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> sudo apt-get update
  File "<stdin>", line 1
    sudo apt-get update
           ^
SyntaxError: invalid syntax
I don't have a problem running this on my PI.
Any idea what's going on? Think Thanks in advance.
That is a Linux command.
On windows use:
python -m pip install -U pip
sudo apt-get update is Linux command, not Python. You need to execute it in the shell/terminal. At the moment you try to execute it in the python interactive prompt.
I get the same thing whether I try it in shell or terminal.
Python 3.6.2 (v3.6.2:5fd33b5, Jul  8 2017, 04:14:34) [MSC v.1900 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> python -m pip install -U pip
SyntaxError: invalid syntax
>>> sudo apt-get update
SyntaxError: invalid syntax
>>> 
This one is from the shell, first one from the terminal.
You are trying to run from the python interpreter.
It is a command line command, so run from there.
(Oct-04-2017, 11:59 PM)Dacdiver Wrote: [ -> ]Python 3.6.2 (v3.6.2:5fd33b5, Jul  8 2017, 04:14:34) [MSC v.1900 32 bit (Intel)] on win32

This is a dead give away you are in the Python shell, as is the >>> prompt. To leave the shell, type exit() , this will return you to the command terminal.

As was pointed out thought, apt-get is a Linux command and will generate an error in Windows. 

What exactly are you trying to do?
Well, it seems that you don't know what is bash shell and Python interpreter. When you open a terminal you see '$' sign at the end of the prompt. This is the bash shell prompt. The Python interpreter prompt is '>>>'. So, in that interpreter you can run only python "commands". In the bash, the one with the '$', you can run linux shell commands and programs. apt-get is such a program so you run it when you see '$' sign at the end of the prompt.
At the end just open a terminal window and run 'sudo apt-get update'.
(Oct-05-2017, 09:11 AM)wavic Wrote: [ -> ]When you open a terminal you see '$' sign at the end of the prompt. This is the bash shell prompt.

(The OP is using Windows 10 :-) ).
I always forget that there is something called Windows  Rolleyes
I think you should use the Terminal of the Raspberry Pi. Inside it you can use the any sudo commands. Using the Python to use sudo commands is a bad idea.
Pages: 1 2