Mac安装python 环境& pychaem
一、文档说明
在Mac上其实自带python环境,但是很多的library安装python是2.7的版本。
验证:可以在终端Terminal中输入:python
如下图是未安装之前,但是咱们需要在自己的Mac上装python 3.0的版本。
![](https://upload-images.jianshu.io/upload_images/24361498-df029b7fcfd02d8a.png?imageMogr2/auto-orient/strip|imageView2/2/w/554/format/webp)
二、python环境安装
1. 在python官网上进行下载应用:https://www.python.org(有时候网络比较慢)
![](https://upload-images.jianshu.io/upload_images/24361498-296dfbb8f837b781.png?imageMogr2/auto-orient/strip|imageView2/2/w/554/format/webp)
2.下载完成之后就能得到一个pkg文件
![](https://upload-images.jianshu.io/upload_images/24361498-91e5594c5e20c887.png?imageMogr2/auto-orient/strip|imageView2/2/w/554/format/webp)
3.直接双击进入到安装页面,点击【继续】,直至出现安装提示
![](https://upload-images.jianshu.io/upload_images/24361498-304263050fa70d85.png?imageMogr2/auto-orient/strip|imageView2/2/w/554/format/webp)
4.在安装提示,直接点击【同意】-【安装】(如果当前系统设置了密码,则在安装的时候会提示你输入密码,你输入密码,点击【立即安装】即可。)
![](https://upload-images.jianshu.io/upload_images/24361498-636a46ebf6dcebf5.png?imageMogr2/auto-orient/strip|imageView2/2/w/554/format/webp)
![](https://upload-images.jianshu.io/upload_images/24361498-f4f737e9439afb90.png?imageMogr2/auto-orient/strip|imageView2/2/w/554/format/webp)
5. 安装完成之后提示如下界面,并且提示安装成功。
![](https://upload-images.jianshu.io/upload_images/24361498-0679993a710d96d5.png?imageMogr2/auto-orient/strip|imageView2/2/w/553/format/webp)
6.此时咱们再打开终端(Terminal)中输入:python3,就会提示如下界面:
![](https://upload-images.jianshu.io/upload_images/24361498-5177c2313c37f639.png?imageMogr2/auto-orient/strip|imageView2/2/w/554/format/webp)
7.【重点】那么为什么不能直接输入python就显示我们3.0的版本呢?
原因:因为python 2.0的版本的环境变量比python 3.0 之前,所以要进行相对应的设置
步骤1: 得到python3的安装路径,打开终端(Terminal)中输入:which python3
![](https://upload-images.jianshu.io/upload_images/24361498-b5ae2ac7ee8a4d52.png?imageMogr2/auto-orient/strip|imageView2/2/w/380/format/webp)
步骤2: 打开.bash_profile文件(可能文件存在,可能不存在,如果第一个命令不行就选择第二个)
第一个:open -e .bash_profile (文件存在)
第二个:vi ~/.bash_profile(文件不存在)
步骤3:[重点]输入如下代码并且command+s进行保存,一定!!!
![](https://upload-images.jianshu.io/upload_images/24361498-ddfbccf8e2472827.png?imageMogr2/auto-orient/strip|imageView2/2/w/579/format/webp)
步骤4:打开终端(Terminal)中输入:source ~/.bash_profile ,再输入:pyhton
![](https://upload-images.jianshu.io/upload_images/24361498-abb9ccf615365156.png?imageMogr2/auto-orient/strip|imageView2/2/w/669/format/webp)
步骤5:做到以上操作你每关闭终端一次,再次打开都需要重新source ~/.bash_profile一下,所以还需要做以下步骤,请一定耐心,马上成功。
在终端输入: 第一步:vi ~/.zshrc 第二步:按i 进行输入,添加:source ~/.bash_profile 第三步: 按esc输入: :wq进行保存退出
![](https://upload-images.jianshu.io/upload_images/24361498-cea194d7973d9852.png?imageMogr2/auto-orient/strip|imageView2/2/w/538/format/webp)
三、安装pycharm
1. 进入到官网:https://www.jetbrains.com/pycharm/download/#section=mac
![](https://upload-images.jianshu.io/upload_images/24361498-8df90d29936c579f.png?imageMogr2/auto-orient/strip|imageView2/2/w/553/format/webp)
2. 得到一个dmg安装包,双击打开,并拖动到Applications
![](https://upload-images.jianshu.io/upload_images/24361498-d8b416b6e6197d8f.png?imageMogr2/auto-orient/strip|imageView2/2/w/554/format/webp)
3. 等待安装后直接打开并新建文件即可,如下即表示安装完成。
![](https://upload-images.jianshu.io/upload_images/24361498-e9a331e36998f71d.png?imageMogr2/auto-orient/strip|imageView2/2/w/554/format/webp)
![](https://upload-images.jianshu.io/upload_images/24361498-392f0e4bb00f97bb.png?imageMogr2/auto-orient/strip|imageView2/2/w/553/format/webp)
文章首发于公号程序员一凡,免费领取软件测试各类学习资源(思维导图+安装包+测试工具+视频教程……)
1、点赞。防止以后找不到,想看的时候,在自己主页就能找到了,很方便;
2、关注我。让我们成为长期关系,下一个文章会分享更多的硬核干货;
3、本文章学习资源,均可以免费分享。