简体   繁体   English

从$ PATH macOS Mojave中删除路径

[英]Remove path from $PATH macOS Mojave

I am trying to set up my new MacBook, and installed python 3.7, however realised that I would rather use python 3.6. 我试图安装新的MacBook,并安装了python 3.7,但是意识到我宁愿使用python 3.6。 I uninstalled python 3.7, however the python path is still in my $PATH alongside the path for python 3.6. 我卸载了python 3.7,但是python路径仍在python 3.6路径中的$ PATH中。 The questions which I have seen on this topic seem to give answers which involve using export PATH which only changes the path for the current session, or say that the measure which needs to be taken depends on your system configuration and version of macOS 我在此主题上看到的问题似乎给出了答案,其中涉及到使用export PATH ,它仅更改当前会话的路径,或者说需要采取的措施取决于您的系统配置和macOS版本。

echo $PATH gives: echo $PATH给出:

/Library/Frameworks/Python.framework/Versions/3.6/bin:/opt/local/bin:/opt/local/sbin:/Library/Frameworks/Python.framework/Versions/3.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:

I have already deleted the ../3.7 which is being pointed to, so would like to only have the 3.6 path in $PATH 我已经删除了../3.7 ,所以只想在$PATH使用3.6路径

Go to your home directory, cd ~ . 转到主目录cd ~

Open .bash_profile file. 打开.bash_profile文件。 Like so, 像这样

open .bash_profile

Make changes to the path variable in the end of the file. 在文件末尾更改path变量。

Save and exit. 保存并退出。

Now close the current terminal and open new one. 现在关闭当前终端并打开新终端。 The changes will sustain. 这些变化将持续下去。

Also for using python of your wish you can alias it in .bash_profile (obviously after setting PATH variable). 另外,如果您希望使用python ,也可以在.bash_profile为其添加别名(显然是在设置PATH变量之后)。

Like, 喜欢,

alias python="python3.6"

You may use export PATH=/Library/Frameworks/Python.framework/Versions/3.6/bin:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin: , but write it in the .bash_profile or the .bashrc in your user. 您可以使用export PATH=/Library/Frameworks/Python.framework/Versions/3.6/bin:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:但是将其写入用户的.bash_profile或.bashrc中。

That is, if you are using bash. 也就是说,如果您正在使用bash。

Maybe you will find already a definition of PATH in there, so you can just change it. 也许您已经在其中找到了PATH的定义,因此您可以更改它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM