samedi 28 février 2015

Python script executable opened by text editor


I have a simple hello world script that i want to turn into an executable. The problem is that even though i went through the steps of declaring the path of the python interpreter in the first list of the code and made it executable via chmod, it does not run as an executable. Instead when i click it my text editor opens up the file. This sounds really stupid but ive tried everything. ./hello.py prints Hello world in the terminal. Ive tried changing the file to open with the terminal instead but its greyed out.



#!/usr/bin/python
print 'Hello world'


What i typed in the terminal:



chmod +x hello.py
./hello.py


Output:



Hello world


Problem: double clicking the script opens text editor instead of running as an executable


What i tried:


Changing what the file uses to open itself by having it default to the terminal but OSX grays out that option.





Aucun commentaire:

Enregistrer un commentaire