Mac更新以後
如果每次打開終端都提示:
The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
原因是原本使用的是bash風格,提示語告知現在新系統的shell已經更換爲zsh,請用此 `chsh -s /bin/zsh` 命令切換。
解決辦法:
(1) 不使用bash,切換zsh,`chsh -s /bin/zsh`命令切換即可。
(2) 繼續使用bash,但又不想出現提示語,則打開文件:
vim ~/.bash_profile
.bash_profile文件最下方加上:
# macOS Catalina
export BASH_SILENCE_DEPRECATION_WARNING=1
然後保存退出
如果使用zsh 虛擬環境命令無效 參照一下
一、根據步驟,當運行source .bash_profile 報錯:
/usr/bin/python: No module named virtualenvwrapper
virtualenvwrapper.sh: There was a problem running the initialization hooks.
If Python could not import the module virtualenvwrapper.hook_loader,
check that virtualenvwrapper has been installed for
VIRTUALENVWRAPPER_PYTHON=/usr/bin/python and that PATH is
set properly.
錯誤原因:Mac安裝了2.7和3.x兩個版本的python,在安裝時使用的是sudo pip3 install virtualenvwrapper
運行的時候默認使用的是python2.x,但在python2.x中不存在對應的模塊。(virtualenvwrapper.sh文件內容如下:):
# Locate the global Python where virtualenvwrapper is installed.
if [ "$VIRTUALENVWRAPPER_PYTHON" = "" ] then
VIRTUALENVWRAPPER_PYTHON="$(command \which python)"
當不存在VIRTUALENVWRAPPER_PYTHON環境時,會默認選擇使用which python(我這裏默認是python2),
所以需要將which python 改爲 which python3 環境:
VIRTUALENVWRAPPER_PYTHON="$(command \which python3)"
二、首先講一下問題原因:zsh的配置文件.zshrc 沒有配置相關環境變量設置
沒有這個文件可以創建一個出來
1、需要將bash 中.bash_profile 環境變量加入zshrc
vim .zshrc
2、添加
source ~/.bash_profile
3、執行下面命令後,問題解決。
source .zshrc