1

I'm using Python 3.5.2.

I'm a beginner with Python and I'm trying to get a path from an input.

However I get this error and I don't understand it.

Traceback (most recent call last):
  File "./install.py", line 12, in <module>
    path = input("Path: ")
  File "<string>", line 1
    /home/nicolas/test.txt
    ^
SyntaxError: invalid syntax

Source:

#! /usr/bin/python
# -*- coding: utf8 -*-

import os
import sys
import time

print('---- Test ----- \n')

time.sleep(1)

path = input("Path: ")

print(path)

Thank's a lot for help!

Royce
  • 1,557
  • 5
  • 19
  • 44
  • 1
    You're not using Python 3.5.2. – vaultah Jan 07 '18 at 17:51
  • Really ? Because when I use `python --version` the result is Python 3.5.2. – Royce Jan 07 '18 at 17:53
  • 1
    I do'nt know if it's the right way but when I use `/usr/bin/python3` it's working. – Royce Jan 07 '18 at 18:05
  • 1
    As evident by the error, your code is interpreted using Python 2.x. Something is wrong with the way you execute the script. If you call it from the command line like `./install.py`, you might need to [fix its shebang](https://stackoverflow.com/questions/6908143/should-i-put-shebang-in-python-scripts-and-what-form-should-it-take). – Norrius Jan 07 '18 at 18:30
  • 1
    N. Lamblin, are you executing the file from the terminal as `python install.py`? If you are, this should help: `python3 install.py` – Oqhax Jan 07 '18 at 19:53
  • @Oqhax I use `./install.py` – Royce Jan 07 '18 at 20:36
  • OK, sorry. Still, could you try `python3 install.py`? Thanks. – Oqhax Jan 09 '18 at 18:20

0 Answers0