0

Hi I am working on project that requires me to use Arabic text in strings and take Arabic text as an input form the user so I have searched on the internet for ways to stop python from giving me an error when I run it so the people suggested to use this at the beginning of the py script:

#! /usr/local/bin/python  -*- coding: UTF-8 -*-

and it worked when running it through IDLE but the problem is when I try running it from cmd it directly crashes and closes, and I am planning to make my code windows and android compatible using kivy. Any help will be really appreciated.

Mohammad Kurjieh
  • 1,043
  • 7
  • 16
  • Not sure if this will make any difference but I think that line should be `#!/usr/bin/env python # -*- coding: UTF-8 -*-` – chickity china chinese chicken Nov 11 '16 at 19:40
  • It runs when in both cases but Do you no a solution for the cmd error? – Mohammad Kurjieh Nov 12 '16 at 18:08
  • What's the output message of the cmd error? – chickity china chinese chicken Nov 12 '16 at 23:28
  • It is so fast that I cann't see it by my eye, you can try it yourself by just saving a .py file just containing #! /usr/local/bin/python -*- coding: UTF-8 -*- and x = 'اللغة العربية' and close the idle and open the file directly by a double click and the cmd will crash and close instantly. – Mohammad Kurjieh Nov 14 '16 at 18:43
  • What do you expect to see? It is happening so fast because your script doesn't do anything, it takes no input and displays no output, so it *should* immediately close that fast. What do you mean "open the file directly by a double click and the cmd will crash and close instantly"? Why double click on the python script? What you mean "the cmd will crash and close"? Why not try running the python script from cmd, as in windows: `C:\Users\MyUser>python myscript.py` and see if it "crashes".. – chickity china chinese chicken Nov 14 '16 at 18:59
  • In my script I have inputs and outputs but this was a small demo to prove my point even if a used time.sleep() after the printing and it will crash – Mohammad Kurjieh Nov 14 '16 at 19:02
  • Running it from cmd worked but the text is not shown properly – Mohammad Kurjieh Nov 14 '16 at 19:06
  • what do you mean "it will crash"? What crashes, the cmd, idle, or python? can you try run your python with `-v` (verbose) flag on your script and see if any debug information is printed before whatever is "crashing" does crash? something like "python -v myscript.py" or "python -v -v myscript.py" for extra debug info.. – chickity china chinese chicken Nov 14 '16 at 19:11
  • if I run it from cmd it won't crash but the arabic letters won't appear correctly and also I am trying to make my py script as an exe will it crash then or it will remain fine? and is their any solution for the font issue? – Mohammad Kurjieh Nov 14 '16 at 19:22
  • I don't know what you mean "will it crash"...will *what* crash? Python scripts don't "crash", they *should* output errors. For the font issue, try http://stackoverflow.com/questions/388490/unicode-characters-in-windows-command-line-how – chickity china chinese chicken Nov 14 '16 at 19:26
  • The cmd was Directly closing even if their is a loop and sleep within it but when I ran the script form cmd this is issue was gone but the 2 problems that rises are that the font is not arabic they are non arabic characters and the other problem is thet when I convert the py script to exe I don't want every time to open the cmd and run not even a batch file I want it to start on its own – Mohammad Kurjieh Nov 14 '16 at 19:31

0 Answers0