Posts: 4
Threads: 1
Joined: Aug 2018
Aug-01-2018, 08:13 PM
(This post was last modified: Aug-01-2018, 08:14 PM by newbie.)
hi
im learning python for about 5 minutes now and trying to run python from a windows terminal(giving the directory to the termminal so the terminal finds and run it) and im having this error:
SyntaxError: unexpected character after line continuation character.
my code is:
C:\> cd Desktop\Python and its the same as the example in the book(Python Crash Course) but i have no clue what is wrong.
any idea what is this for?
OS: Windows 10
Python V 3.7.0
Posts: 12,031
Threads: 485
Joined: Sep 2016
this is not code, it's a OS command to change directory
C:\> cd Desktop\Python from command line, if you want interactive python, simply type:
python if you want to run a python script, for example myscript.py, use:
python myscript.py
Posts: 4,220
Threads: 97
Joined: Sep 2016
That's not Python. That's the Windows command to change directories. You would type that at the Windows command line to get to the Python folder on your desktop.
Posts: 4
Threads: 1
Joined: Aug 2018
Aug-05-2018, 07:29 PM
(This post was last modified: Aug-05-2018, 07:29 PM by newbie.)
(Aug-01-2018, 09:07 PM)Larz60+ Wrote: this is not code, it's a OS command to change directory
C:\> cd Desktop\Python from command line, if you want interactive python, simply type:
python if you want to run a python script, for example myscript.py, use:
python myscript.py
lol, thx but got nothing out of it yet.
error is (in the os command window):'C:\' is not recognized as an internal or external command,
operable program or batch file.
tried this with all three ways u said and still nothing.
checked the directory and it was not wrong.
Posts: 12,031
Threads: 485
Joined: Sep 2016
drop c:\
type what I show verbatim
Posts: 4
Threads: 1
Joined: Aug 2018
(Aug-05-2018, 08:47 PM)Larz60+ Wrote: drop c:\
type what I show verbatim
still nothing, just an "invalid syntax" error.
copied ur lines and changed my folder names to them exactly.
thx tho, maybe i can find the way to do this on utube.
Posts: 12,031
Threads: 485
Joined: Sep 2016
please show everything on your screen, including prompts, etc.
There is something wrong here,
for example if you see >>>
show that and everything else.
Posts: 4
Threads: 1
Joined: Aug 2018
Aug-09-2018, 06:08 AM
(This post was last modified: Aug-09-2018, 06:08 AM by newbie.)
(Aug-06-2018, 07:55 PM)Larz60+ Wrote: please show everything on your screen, including prompts, etc.
There is something wrong here,
for example if you see >>>
show that and everything else.
this is what happens in command window:
C:\Users\admin\Desktop>C:\> cd Desktop\Python
'C:\' is not recognized as an internal or external command,
operable program or batch file.
it also makes a file named "cd" in my desktop and its empty.
Posts: 12,031
Threads: 485
Joined: Sep 2016
Aug-09-2018, 12:28 PM
(This post was last modified: Aug-09-2018, 12:29 PM by Larz60+.)
[python]cd stands for change directory.
Why are you trying to change director while trying to run python?
type the following verbatim from command line:
Output: python
nothing more, nothing less. Got it???
Posts: 7,320
Threads: 123
Joined: Sep 2016
Aug-09-2018, 06:04 PM
(This post was last modified: Aug-09-2018, 06:05 PM by snippsat.)
cmd tutorial
Python 3.6/3.7 and pip installation under Windows
A run in cmd:
Microsoft Windows [Version 10.0.17134.165]
(c) 2018 Microsoft Corporation. Med enerett.
# Change directory to root C:
C:\Windows\System32>cd\
# Test Python
C:\>python -V
Python 3.7.0
# Test pip
C:\>pip -V
pip 18.0 from c:\python37\lib\site-packages\pip (python 3.7)
# Change directory to foo:
C:\>cd foo
# look at hello.py
C:\foo>more hello.py
print('hello world')
# Run hello.py
C:\foo>python hello.py
hello world
# Interactive interpreter
C:\foo>python
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:06:47) [MSC v.1914 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> a = 'foo'
>>> a * 5
'foofoofoofoofoo'
>>> exit()
C:\foo> When i type command is only text marked in blue.
C:\Windows\System32> cd\
C:\foo> python hello.py
C:\foo> more hello.py
|