我想從桌面雙擊運行python項目。 我設法找到了shebang的路徑。我也將擴展名從.py改爲.command。我也運行了chmod + x name_of_script.py,據說它可以像我希望的那樣運行它。雖然當我點擊它發生這種情況:點擊運行python項目
Last login: Wed Jul 19 13:38:24 on ttys000
___________:~ _____$ path filename.command ; exit;
Traceback (most recent call last):
File "path filename.command", line 2, in <module>
import pygame
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pygame/__init__.py", line 95, in <module>
from pygame.base import *
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pygame/base.so, 2): no suitable image found. Did find:
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pygame/base.so: no matching architecture in universal wrapper
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pygame/base.so: no matching architecture in universal wrapper
logout
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.
Deleting expired sessions...8 completed.
[Process completed]
PS:我改變了「文件路徑」,並與_____所有私人名稱的所有文件路徑。
我試圖運行的文件叫做文件名。
你使用什麼操作系統? – bakatrouble
[雙擊運行Python文件]的可能重複(https://stackoverflow.com/questions/41639740/running-python-file-by-double-click) –
我們從askubuntu的朋友有一個帖子來解決您的問題:) https://askubuntu.com/questions/596793/make-a-python-program-executable-from-its-icon –