无法在mac上导出PATH

时间:2016-06-01 03:41:32

标签: macos

我将我的python bin文件夹添加到环境变量PATH

export PATH=$PATH:/Library/Frameworks/Python.framework/Versions/2.7/bin

但是以下声明失败了

set: Warning: path component /usr/local/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin may not be valid in PATH.
set: No such file or directory
set: Did you mean 'set PATH $PATH /Library/Frameworks/Python.framework/Versions/2.7/bin'?
set: Warning: path component /usr/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin may not be valid in PATH.
set: No such file or directory
set: Did you mean 'set PATH $PATH /Library/Frameworks/Python.framework/Versions/2.7/bin'?
set: Warning: path component /bin:/Library/Frameworks/Python.framework/Versions/2.7/bin may not be valid in PATH.
set: No such file or directory
set: Did you mean 'set PATH $PATH /Library/Frameworks/Python.framework/Versions/2.7/bin'?
set: Warning: path component /usr/sbin:/Library/Frameworks/Python.framework/Versions/2.7/bin may not be valid in PATH.
set: No such file or directory
set: Did you mean 'set PATH $PATH /Library/Frameworks/Python.framework/Versions/2.7/bin'?
set: Warning: path component /sbin:/Library/Frameworks/Python.framework/Versions/2.7/bin may not be valid in PATH.
set: No such file or directory...

发生什么事了?我和其他人一样做(谷歌搜索)。使用的壳是鱼。

2 个答案:

答案 0 :(得分:4)

您使用的bash(或ksh)语法在fish中不起作用。

鱼类文档包括在此处设置PATH:http://fishshell.com/docs/current/tutorial.html#tut_path

您想要的语法是:

set PATH $PATH /Library/Frameworks/Python.framework/Versions/2.7/bin

答案 1 :(得分:0)

我已经尝试过Macbook Pro,通过编辑文件~/.bash_profile,它可以正常工作。您可以在下面看到示例: 但是这项工作对我来说只是暂时的,在关闭终端后我需要运行 再次source ~/.bash_profile

set JAVA_HOME /Library/Java/JavaVirtualMachines/jdk1.8.0_73.jdk/Contents/Home
set MAVEN_HOME /opt/apache-maven-3.3.9/bin
set XAMP_HOME /Applications/XAMPP/xamppfiles/bin
set ANDROID_HOME /Users/sochy/Documents/sdk
set ZIPALIGN /Users/sochy/Documents/sdk/build-tools/23.0.2
set GOPATH $HOME/go
set PORT /opt/local/bin
set PATH $PATH $JAVA_HOME $MAVEN_HOME $XAMP_HOME $ANDROID_HOME $ZIPALIGN $GOPATH $PORT $HOME/flutter/bin

我尝试在下面尝试通过编辑文件源~/.bash_profile进行永久配置,然后重新启动终端的另一种解决方案

export JAVA_HOME=Library/Java/JavaVirtualMachines/jdk1.8.0_73.jdk/Contents/Home
export MAVEN_HOME=opt/apache-maven-3.3.9/bin
export XAMP_HOME=Applications/XAMPP/xamppfiles/bin
export ANDROID_HOME=Users/sochy/Documents/sdk
export ZIPALIGN=Users/sochy/Documents/sdk/build-tools/23.0.2
export GOPATH=$HOME/go
export PORT=opt/local/bin
export PATH=${PATH}:$JAVA_HOME:$MAVEN_HOME:$XAMP_HOME:$ANDROID_HOME:$ZIPALIGN:$GOPATH:$PORT:$HOME/flutter/bin