[英]Running python3 programs on osx Lion
I can use python 3 in terminal fine, but I don't know how to make it so terminal will run a program that I have written in python 3. 我可以在终端中使用python 3,但是我不知道如何制作它,因此终端将运行我用python 3编写的程序。
What do i have to do to associate the .py file extension with python3.2.3 for terminal and not python2.7.1 我应该怎么做才能将.py文件扩展名与python3.2.3关联用于终端而不是python2.7.1
I am using textwrangler as my text editor, but will happily use any editor if it will run, though I don't think this is my problem as idle doesn't work either and it doesn't have line numbers in it either. 我使用textwrangler作为我的文本编辑器,但是会运行任何编辑器,尽管我不认为这是我的问题,因为闲置也不起作用,也没有行号。
Kind regards 亲切的问候
Rob 抢
Add a python3
hashbang to the beginning of your scripts: 在脚本的开头添加
python3
hashbang:
#!/usr/bin/env python3
# do stuff
Then, you can make your script executable and run it: 然后,可以使脚本可执行并运行它:
chmod +x script.py
./script.py
try python3 yourprogram.py
in your terminal. 在终端中尝试
python3 yourprogram.py
。
or by adding this line on the top of our programs, this is the path to your interpreter: 或通过在我们的程序顶部添加此行,这是您的解释器的路径:
#!/usr/local/bin/python3.2
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.