Mac下安装 brew, python3.7,pycharm,pip, ipython

安装 brew

 

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

 

安装python3.7

macOS系统自带python2.7, 我们要使用python3只能自行安装

由于在线下载,网速太慢了。所以选择在python官网,下载python3.7.3 for macOS

跟一般的应用一样,安装即可。

然后配置python3,跟自带python2.7区分开,可自由切换

命令行输入:

vi ~/.bash_profile

按 i 键进入编辑状态,在末尾 将以下代码复制粘贴进去,然后按 esc 退出编辑,按  :wq  保存退出

# Setting PATH for Python 2.7
PATH="/System/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH
# Setting PATH for Python 3.7.3
PATH="/usr/local/Cellar/python/3.7.3/bin:${PATH}"

继续命令行输入:

vi ~/.bashrc

 

按 i 键进入编辑状态,将以下代码复制粘贴进去,然后按 esc 退出编辑,按  :wq  保存退出

alias python2='/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7'
alias python3='/usr/local/Cellar/python/3.7.3/bin/python3.7'
# alias python=python3

上述步骤的修改,虽然保存了,但是系统还没让其生效,所以我们需要source一下。

控制台输入:source ~/.bash_profile 然后按回车键

控制台输入:source ~/.bashrc 然后按回车键。

最后关闭终端,重新打开,即生效。

输入python打开自带的python2.7

输入python3 打开python3.7.3

 

安装pycharm

直接在pycharm官网下载pycharm for macOS

参照python3的安装

 

安装 pip 

命令行下输入:

curl https://bootstrap.pypa.io/get-pip.py | python3

由于连接的是国外的网站,所以网速可能很慢,出现请求超时等情况,多试几次。

keendeMac:~ keen$ curl https://bootstrap.pypa.io/get-pip.py | python3
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 1669k  100 1669k    0     0  40512      0  0:00:42  0:00:42 --:--:--  346k
Collecting pip
  Downloading https://files.pythonhosted.org/packages/5c/e0/be401c003291b56efc55aeba6a80ab790d3d4cece2778288d65323009420/pip-19.1.1-py2.py3-none-any.whl (1.4MB)
     |████████████████████████████████| 1.4MB 170kB/s 
Collecting wheel
  Downloading https://files.pythonhosted.org/packages/bb/10/44230dd6bf3563b8f227dbf344c908d412ad2ff48066476672f3a72e174e/wheel-0.33.4-py2.py3-none-any.whl
Installing collected packages: pip, wheel
  Found existing installation: pip 19.0.3
    Uninstalling pip-19.0.3:
      Successfully uninstalled pip-19.0.3
Successfully installed pip-19.1.1 wheel-0.33.4

出现以上,恭喜  pip 安装成功,  我们可以使用命令  sudo pip install 各种python包了

 

安装 ipython

命令行下:

sudo pip install ipython

keendeMac:~ keen$ sudo pip install ipython
WARNING: The directory '/Users/keen/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
WARNING: The directory '/Users/keen/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting ipython
  Downloading https://files.pythonhosted.org/packages/a9/2e/41dce4ed129057e05a555a7f9629aa2d5f81fdcd4d16568bc24b75a1d2c9/ipython-7.5.0-py3-none-any.whl (770kB)
     |████████████████████████████████| 778kB 70kB/s 
Collecting backcall (from ipython)
  Downloading https://files.pythonhosted.org/packages/84/71/c8ca4f5bb1e08401b916c68003acf0a0655df935d74d93bf3f3364b310e0/backcall-0.1.0.tar.gz
Collecting pickleshare (from ipython)
  Downloading https://files.pythonhosted.org/packages/9a/41/220f49aaea88bc6fa6cba8d05ecf24676326156c23b991e80b3f2fc24c77/pickleshare-0.7.5-py2.py3-none-any.whl
Collecting decorator (from ipython)
  Downloading https://files.pythonhosted.org/packages/5f/88/0075e461560a1e750a0dcbf77f1d9de775028c37a19a346a6c565a257399/decorator-4.4.0-py2.py3-none-any.whl
Collecting pygments (from ipython)
  Downloading https://files.pythonhosted.org/packages/5c/73/1dfa428150e3ccb0fa3e68db406e5be48698f2a979ccbcec795f28f44048/Pygments-2.4.2-py2.py3-none-any.whl (883kB)
     |████████████████████████████████| 890kB 85kB/s 
Collecting pexpect; sys_platform != "win32" (from ipython)
  Downloading https://files.pythonhosted.org/packages/0e/3e/377007e3f36ec42f1b84ec322ee12141a9e10d808312e5738f52f80a232c/pexpect-4.7.0-py2.py3-none-any.whl (58kB)
     |████████████████████████████████| 61kB 249kB/s 
Collecting appnope; sys_platform == "darwin" (from ipython)
  Downloading https://files.pythonhosted.org/packages/87/a9/7985e6a53402f294c8f0e8eff3151a83f1fb901fa92909bb3ff29b4d22af/appnope-0.1.0-py2.py3-none-any.whl
Requirement already satisfied: setuptools>=18.5 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from ipython) (40.8.0)
Collecting traitlets>=4.2 (from ipython)
  Downloading https://files.pythonhosted.org/packages/93/d6/abcb22de61d78e2fc3959c964628a5771e47e7cc60d53e9342e21ed6cc9a/traitlets-4.3.2-py2.py3-none-any.whl (74kB)
     |████████████████████████████████| 81kB 166kB/s 
Collecting prompt-toolkit<2.1.0,>=2.0.0 (from ipython)
  Downloading https://files.pythonhosted.org/packages/f7/a7/9b1dd14ef45345f186ef69d175bdd2491c40ab1dfa4b2b3e4352df719ed7/prompt_toolkit-2.0.9-py3-none-any.whl (337kB)
     |████████████████████████████████| 337kB 142kB/s 
Collecting jedi>=0.10 (from ipython)
  Downloading https://files.pythonhosted.org/packages/25/2b/1f188901be099d52d7b06f4d3b7cb9f8f09692c50697b139eaf6fa2928d8/jedi-0.13.3-py2.py3-none-any.whl (178kB)
     |████████████████████████████████| 184kB 143kB/s 
Collecting ptyprocess>=0.5 (from pexpect; sys_platform != "win32"->ipython)
  Downloading https://files.pythonhosted.org/packages/d1/29/605c2cc68a9992d18dada28206eeada56ea4bd07a239669da41674648b6f/ptyprocess-0.6.0-py2.py3-none-any.whl
Collecting six (from traitlets>=4.2->ipython)
  Downloading https://files.pythonhosted.org/packages/73/fb/00a976f728d0d1fecfe898238ce23f502a721c0ac0ecfedb80e0d88c64e9/six-1.12.0-py2.py3-none-any.whl
Collecting ipython-genutils (from traitlets>=4.2->ipython)
  Downloading https://files.pythonhosted.org/packages/fa/bc/9bd3b5c2b4774d5f33b2d544f1460be9df7df2fe42f352135381c347c69a/ipython_genutils-0.2.0-py2.py3-none-any.whl
Collecting wcwidth (from prompt-toolkit<2.1.0,>=2.0.0->ipython)
  Downloading https://files.pythonhosted.org/packages/7e/9f/526a6947247599b084ee5232e4f9190a38f398d7300d866af3ab571a5bfe/wcwidth-0.1.7-py2.py3-none-any.whl
Collecting parso>=0.3.0 (from jedi>=0.10->ipython)
  Downloading https://files.pythonhosted.org/packages/a7/bd/e2f4753c5fa93932899243b4299011a757ac212e9bc8ddf062f38df4e78b/parso-0.4.0-py2.py3-none-any.whl (94kB)
     |████████████████████████████████| 102kB 143kB/s 
Building wheels for collected packages: backcall
  Building wheel for backcall (setup.py) ... done
  Stored in directory: /Users/keen/Library/Caches/pip/wheels/98/b0/dd/29e28ff615af3dda4c67cab719dd51357597eabff926976b45
Successfully built backcall
Installing collected packages: backcall, pickleshare, decorator, pygments, ptyprocess, pexpect, appnope, six, ipython-genutils, traitlets, wcwidth, prompt-toolkit, parso, jedi, ipython
Successfully installed appnope-0.1.0 backcall-0.1.0 decorator-4.4.0 ipython-7.5.0 ipython-genutils-0.2.0 jedi-0.13.3 parso-0.4.0 pexpect-4.7.0 pickleshare-0.7.5 prompt-toolkit-2.0.9 ptyprocess-0.6.0 pygments-2.4.2 six-1.12.0 traitlets-4.3.2 wcwidth-0.1.7
keendeMac:~ keen$ ipython
Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 16:52:21) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.5.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]:

 

网速慢下载超时安装失败,就多试几次。

 

你可能感兴趣的:(Mac下安装 brew, python3.7,pycharm,pip, ipython)