Ubuntu 18
My Python3 script code:

#!/usr/bin/env python3 # -*- coding: utf-8 -*- from PIL import Image outnamefile = str(input("имя выходного файла: ")) im = Image.open("1.jpg") out = im.thumbnail(700, 700) out.save(outnamefile + ".jpg", "jpeg") 

When executing it in Pycharm everything is error free. When executing the code by double clicking on the file with the script (there is a tick "allow the execution of the file as a program"), an error is displayed:

  имя выходного файла: swde Traceback (most recent call last): File "resize_img.py", line 4, in <module> outnamefile = str(input("имя выходного файла: ")) File "<string>", line 1, in <module> NameError: name 'swde' is not defined 

If you run the script through the terminal: python3 resize_ing.py Everything works well. Although the shebang is filled correctly, the script seems to run through Python2.

How to correct, that by a click on a file the script python version intended for this or that script was executed?

Python is worth 3.6.

 Команда ~$ which python3 /usr/bin/python3 
  • outnamefile = str (input ("output file name:")). Here, specifically str is not important. I forgot to correct the question before publishing. Swears on input. - suvorov.mo
  • Yes. Read carefully: (there is a tick "allow the execution of the file as a program"). well, or x - suvorov.mo
  • And, yes, inattentively read. Then to another: double click in which file manager? - andreymal
  • "Files 3.26.3" default manager ubuntu18. According to the settings as a nautilus. - suvorov.mo
  • My Nautilus 3.26.3 in my ubunt 18 perfectly listens to the shebang and launches everything with the third python - andreymal

0