Mac下安装使用Python与VS Code设置

查看版本

python3 -V
Python 3.7.0

pip3 -V
pip 10.0.1 from /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip (python 3.7)

# 进入查看自带python情况
cd /System/Library/Frameworks/Python.framework/Versions

# python3的位置
/Library/Frameworks/Python.framework/Versions/3.7/bin
# pip位置
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip

更改默认


# 终端打开.bash_profile文件
open ~/.bash_profile

PATH="/Library/Frameworks/Python.framework/Versions/3.7/bin:${PATH}"
export PATH
 
# 添加别名
alias python="/Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7"

# 终端中重新读取.bash_profile文件
source .bash_profile

VS Code

  • 在用户设置中添加python3的路径
    “python.pythonPath”: “/usr/local/bin/python3.7”

  • 同时在launch.json文件中添加
    ”pythonPath”: “${config:python.pythonPath}”。

代码

#查看版本
import sys 
print(sys.version)
发布了123 篇原创文章 · 获赞 114 · 访问量 3万+

猜你喜欢

转载自blog.csdn.net/yuhezheg/article/details/104398593