对于Mac、Linux系统,Anaconda安装好后,实际上就是在主目录下多了个文件夹(
~/anaconda
)而已,Windows会写入注册表。安装时,安装程序会把bin目录加入PATH(Linux/Mac写入~/.bash_profile
,Windows添加到系统变量PATH)
这些操作也完全可以自己完成。以Linux/Mac为例,安装完成后设置PATH的操作是
1 2 3 4 5 |
# 将anaconda的bin目录加入PATH,根据版本不同,也可能是~/anaconda2/bin echo 'export PATH="~/anaconda/bin:$PATH"' >> ~/.bash_profile # 更新bashrc以立即生效 source ~/.bash_profile |
查看.bash_profile
,在Terminal输入
1 2 |
vim .bash_profile |
得到(20170725)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# Setting PATH for Python 3.4 # The orginal version is saved in .bash_profile.pysave PATH="/Library/Frameworks/Python.framework/Versions/3.4/bin:${PATH}" export PATH # Setting PATH for MacPython 2.6 # The orginal version is saved in .bash_profile.pysave PATH="/Library/Frameworks/Python.framework/Versions/2.6/bin:${PATH}" export PATH # Setting PATH for MacPython 2.6 # The orginal version is saved in .bash_profile.pysave PATH="/Library/Frameworks/Python.framework/Versions/2.6/bin:${PATH}" export PATH # added by Anaconda2 2.4.0 installer export PATH="//anaconda/bin:$PATH" ## # Your previous /Users/huwei/.bash_profile file was backed up as /Users/huwei/.bash_profile.macports-saved_2016-02-28_at_20:48:48 ## |
Vim模式下,按Command+:
输入x
即可保存并退出。
配置好PATH后,可以通过which conda
或conda --version
命令检查是否正确。假如安装的是Python 2.7对应的版本,运行python --version
或python -V
可以得到Python 2.7.12 :: Anaconda 4.1.1 (64-bit),也说明该发行版默认的环境是Python 2.7。
(iTerm on Mac)
1 2 3 4 5 6 7 |
➜ ~ which conda /Users/huwei/anaconda/bin/conda ➜ ~ conda --version conda 4.3.21 ➜ ~ python --version Python 2.7.13 :: Anaconda 4.4.0 (x86_64) |
知乎:怎么在mac 系统上使用Python?怎么安装Anaconda?
conda vs. pip vs. virtualenv
简书:Anaconda使用总结
请问 Mac OS X 的 .bash_profile 文件在哪里,怎么编辑啊?
You must be logged in to post a comment.
Be the first to comment.