# Python Library Path ###### tags: `Ubuntu` ## Mac 首先開啟配置檔案 open ~/.bash_profile 然後修改你的Python路徑,我自己安裝的Python是3.7 (路徑是: /Library/Frameworks/Python.framework/Versions/ ) (另外,系統自帶的Python路徑是 /System/Library/Frameworks/Python.framework/Versions/ ) 在開啟的檔案新增如下兩行命令 export PATH=${PATH}:/Library/Frameworks/Python.framework/Versions/3.7/bin alias python="/Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7" 最後儲存檔案並關閉 在終端中執行 source ~/.bash_profile ## Ubuntu 更改Ubuntu默认Python版本方法 一般Ubuntu默认的Python版本都为2.x, 如何改变Python的默认版本呢? 假设我们需要把Python3.5设置为默认版本: 首先查看Python默认版本: ```shell= ubuntu@user~$:python --version Python 2.7 ``` 搜索系统是否已经安装Python3.5: ```shell= ubuntu@user~$:whereis python3.5 ``` 安装完成后,需要删除原有的Python连接文件: ```shell= ubuntu@user~:sudo rm /usr/bin/python ``` 然后建立指向Python3.5的软连接: ```shell= ubuntu@user~:sudo ln -s /usr/bin/python3.5 /usr/bin/python ``` 之后把路径/usr/bin/加入环境变量PATH中: ```shell= ubuntu@user~:PATH=/usr/bin:$PATH ``` 现在输入python --version你就会发现python默认版本变为Python3.5了:)