Mac下切換Python版本

1.查看python版本

<code>/usr/bin/python
Jiaheng:~ jiaheng$ which python3
/Library/Frameworks/Python.framework/Versions/3.8/bin/python3
Jiaheng:~ jiaheng$ which python3.8
/Library/Frameworks/Python.framework/Versions/3.8/bin/python3.8
/<code>

2.修改版本

  • 修改用戶根目錄下的~/.bash_profile文件,在終端輸入:
<code>Jiaheng:~ jiaheng$ open ~/.bash_profile
/<code>
  • 在文件中新增一行:
<code>alias python=”/Library/Frameworks/Python.framework/Versions/3.8/bin/python3.8″
/<code>
  • 添加完之後執行:
<code>Jiaheng:~ jiaheng$ source ~/.bash_profile/<code>
  • 驗證:
<code>Jiaheng:~ jiaheng$ python –version/<code>


Mac下切換Python版本


分享到:


相關文章: