Reputation: 1095
I have python code that works in command prompt(Windows) using python file.py
command, but when I copy this code and put it inside server, it does not work. (it gives me an error which does not occur when executed in command prompt)
Both Windows and server(ubuntu; it uses django as framework) use same version of Python - 3.5.2
Any advice or suggestion would be appreciated. Thank you in advance.
Here is the part of the code which gives me error (local variable 'district' referenced before assignment) only on server.
def GetDistrict_driver(addr):
district = ''
if addr == 'Seoul':
district = 'S1'
elif addr == 'Incheon':
district = 'A1'
elif addr == 'Daejeon':
district = 'B1'
elif addr == 'Gwangju':
district = 'C1'
elif addr == 'Daegu':
district = 'D1'
elif addr == 'Ulsan':
district = 'E1'
elif addr == 'Busan':
district = 'F1'
return district
Upvotes: 2
Views: 212
Reputation: 2627
For the server try this command:
python3 file.py
Edited: In some linux based os there is difference calling python scripts with "python" and "python3" - first one calls the python2.7 interpreter and the second one - python 3 interpreter.
Upvotes: 1