Mac中Python版本随意切换终极指南,简单到爆,什么都不用设置

版权声明:转载请通过公众号《湾区人工智能》联系我授权,谢谢 https://blog.csdn.net/BTUJACK/article/details/83989215

很多人为了Mac自带Python和自己下载的Python冲突发生烦恼,我一开始也很烦恼,现在彻底搞定了,这篇文章就是解决这个困扰而设置的。

这篇文章是继这篇文章后总结出的

简单3步成功给Mac安装指定Python版本和指定库版本并且随意切换版本,非常简单,不行拿砖砸我

https://blog.csdn.net/BTUJACK/article/details/83821642

再次总结后发现,根本没必要设置任何东西呀,请看下文

 

我的电脑有3个Python:

2.7,系统自带,

3.5,官网手动下载

3.7  brew intall python3 自动下载

他们三个和谐相处,颈部惊喜!!!

方法:

在指定文件夹中打开终端

mac在当前文件夹打开终端方法,献给不喜欢终端打字的小伙伴

https://blog.csdn.net/BTUJACK/article/details/83989099

终端运行文件只需要这么一行就行了

python3.5 test.py

或者

python3.7 test.py

等,自己依次设置

建立一个test.py文件,写入:print('使用Python3.7')

终端运行看看效果:


Last login: Mon Nov 12 11:20:13 on ttys000

test.py写了使用Python2.7,因为有汉子,报错,同样汉字,Python3.7没有报错

appledeMBP:python apple$ python2.7 test.py
  File "test.py", line 1
SyntaxError: Non-ASCII character '\xe4' in file test.py on line 1, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
appledeMBP:python apple$ python3.5 test
/Library/Frameworks/Python.framework/Versions/3.5/Resources/Python.app/Contents/MacOS/Python: can't open file 'test': [Errno 2] No such file or directory

appledeMBP:python apple$ python3.5 test.py
使用Python3.5

appledeMBP:python apple$ python3.7 test.py
使用Python3.7
appledeMBP:python apple$ 

就是这么easy

如果你使用sublime text,随意切换版本也超级方便,看这里

Mac给Sublime Text 配置Python3开发环境

https://blog.csdn.net/BTUJACK/article/details/83828953

如果想给对应的Python版本下载库,也很简单,看这里

给指定Python版本安装指定版本库的办法

https://blog.csdn.net/BTUJACK/article/details/83858638

这么看来根本不用管Python安装哪里了,如果你要看路径,点击

Mac查看Python安装路径和版本

https://blog.csdn.net/BTUJACK/article/details/83856274

妈妈再也不用担心我为Python版本而烦恼了,

使用Mac电脑几个月整理而成,如果能帮到大家,请点赞,留言支持,谢谢

认识你是我们的缘分,同学,等等,学习人工智能,记得关注我。

微信扫一扫
关注该公众号

《湾区人工智能》

猜你喜欢

转载自blog.csdn.net/BTUJACK/article/details/83989215
今日推荐