java安装
地址: http://www.oracle.com
- 如果你是第一次配置环境变量,可以使用
touch .bash_profile
创建一个.bash_profile的隐藏配置文件(如果你是为编辑已存在的配置文件,则使用open -e .bash_profile
命令):
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk12.0.1.jdk/Contents/Home
PATH=$JAVA_HOME/bin:$PATH:.
CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:.
export JAVA_HOME
export PATH
export CLASSPATH
- 使用命令生效
source .bash_profile
python安装
地址: https://www.python.org/
查看地址: which python
- 如果你是第一次配置环境变量,可以使用
touch .bash_profile
创建一个.bash_profile的隐藏配置文件(如果你是为编辑已存在的配置文件,则使用open -e .bash_profile
命令):
# Setting PATH for Python 2.7
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH
alias python="/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7"
前提是你安装了xcode
并且运行过,要不然后面会报错
在安装最新版Python3.*之前,我们先熟悉一下系统自带的python
Mac系统自带python路径为/System/Library/Frameworks/Python.framework/Version,我们先来打开目录看一下:
open /System/Library/Frameworks/Python.framework/Versions
安装前先搜索一下是否已经存在python3的包:
brew search python3
已经存在,我们可以直接安装了:
brew install python3
所有的包都下载完毕,但是我们却发现最后报了两条错误,大概意思是公式已经建立,但是在创建连接的时候因为没有权限而发生意外错误。在报错信息里我们看到一个目录/usr/local/Frameworks,我们先去找一下这个目录:
open /usr/local/Frameworks
发现这个目录竟然不存在,那我们就来手动创建一个:
sudo