mac电脑配置python环境

以前一直使用的是 anaconda,但是后来发现 anaconda 太大了,自己也用不完自带的类库,所以把 anaconda 换成 python 官方版本,借此记录一下

卸载 anaconda

1
2
3
4
5
shell> open ~/.bash_profile
#  删除 anaconda bin 的配置,因为anaconda安装程序在~/.bash_profile脚本中新添加了一行,将anaconda bin目录添加到了$PATH环境变量中
shell> source ~/.bash_profile
shell> rm -rf 〜/anaconda  ~/.condarc  ~/.conda  ~/.continuum
# 删除可能在主目录中创建的.condarc文件和.conda以及.continuum目录

  执行完以上操作后重启计算机

安装 Python

  因为我是 mac。所以采用的是 brew 安装

1
shell> brew install python@3

使用 Python3

  因为目前 mac 系统自带 python2.x,所以目前电脑上 python2.x 和 python3.x 都是可以用

  使用 python2.x

1
2
3
4
5
shell> python
Python 2.7.10 (default, Aug 17 2018, 19:45:58)
[GCC 4.2.1 Compatible Apple LLVM 10.0.0 (clang-1000.0.42)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>

  使用 python3.x

1
2
3
4
5
shell> python3
Python 3.7.1 (default, Nov  6 2018, 18:46:03)
[Clang 10.0.0 (clang-1000.11.45.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>

安装 Pycharm

简介

  pycharm 是一款针对 python 开发的优秀的 IDE, 以下是针对其在 mac 上的开发配置使用

安装

1
shell>brew cask install pycharm

  安装完成后双击打开应用

修改主题

  pycharm 默认的主题并不好看, 不过也提供了一些其他的选择,

  这里我们选择Dacula的主体,

  设置的路径是Preference->Appearence & Behavior->Appearence

  

https://image.coderlab.cn/preview/1438621378340208641

  效果如下

  

https://image.coderlab.cn/preview/1438621402763640834

python 环境配置

  py 开发当然是要设置好环境了

1
Preference->project->Project Interpreter

  

https://image.coderlab.cn/preview/1438621417137520641

  

https://image.coderlab.cn/preview/1438621434871037953

  到此为止 mac 电脑上 python 环境已经配置完成