0

Hello All I am in the process of making a script that requires input form the user to be passed to my code i.e enter the file path. it all works well with in python but if I run my script from windows(cmd) each time the input is entered the script crashes with syntax error.

import os 

search_path = input("Enter directory path to search : ")

for folder, dirs, files in os.walk(search_path):

      blah, blah

Anyone got any clues to what i am missing (note: using Python 3.6)

tso
  • 4,732
  • 2
  • 22
  • 32
ISO1337
  • 3
  • 1
  • I assume you're running `python script.py`. What's printed for `python --version`, and what's the printed path for `where python`? – Eryk Sun Jun 01 '17 at 01:09
  • python --version give the response of Python 3.6. but it seems there was two version of python installed (2.7) and my Windows environment path was set for version 2.7 to seem i install 3.6 then uninstall 2.7 and did not update my environment path. now it all works thanks very much for your help :) – ISO1337 Jun 01 '17 at 16:15

1 Answers1

0

i also have windows and python 3.6 i have tried your code above and worked fine for me

import os
sp=input('enter directory path to search: \n')
for folder,dirs,files in os.walk(sp):
    print('sss')

i think you have 2 different version of python installed alongside. check the version from cmd type

python --version

and if it shows 2.x then try from python3 look at here for running multiple version of python

Bibek Ghimire
  • 522
  • 1
  • 4
  • 19
  • python --version give the response of Python 3.6. but it seems there was two version of python installed (2.7) and my Windows environment path was set for version 2.7 to seem i install 3.6 then uninstall 2.7 and did not update my environment path. now it all works thanks very much for your help :) – ISO1337 Jun 01 '17 at 16:15