Mac运行Python程序

1,494 阅读1分钟

Mac运行Python程序

一、如何运行.python文件

方法一:在终端中执行

python test.py

方法二:使用Python Launcher

新建一个.py的文本,在文本顶部指定python的版本。如图:

1.jpg

然后对着.py文件进行右键,选择Python Launcher进行打开,Python Launcher配置如图:

2.jpg

二、可能出现的问题

  1. 运行python程序时,提示No module named 'requests',说明此时没有安装requests,在命令行中安装,输入命令:pip install requests,如提示command not found,则应输入:pip3 install requests。 缺什么模块就安装什么模块。