# 背景:
由于我想更新pip3的version,一直提示如下:
WARNING: You are using pip version 21.2.4; however, version 24.1.2 is available.
You should consider upgrading via the '/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/bin/python3 -m pip install --upgrade pip' command.
1
2
2
但是在我执行这个的时候并没用作用,并且报错一致。所以我便在阿里通义的指引下执行vim ~/.zshrc,并在其中添加了export PATH="/Users/bjys/Library/Python/3.9/bin:$PATH"。<br />如果按照正常的情况下,这样只是修改一个环境变量并没有任何问题,但是我的环境变量中有一个异常的bug,原始的命令大概是在一个export之前有一个" ' "和末尾有":true"我并未注意(/Users/bjys/.zshrc:export:8: not valid in this context: IDEA.app/Contents/plugins/maven/lib/maven3/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/bjys/IdeaProjects/ai-ui-admin/node_modules/.bin:true)<br />在执行source ~/.zshrc更新配置后,由于我的配置文件报错,就导致这个文件无法正常生效,从而导致我的很多基础命令无法使用,如:more、vim、cat、ll、ls等.
bjys@localhost ~ % pip --version
zsh: command not found: pip
bjys@localhost ~ % pip3 --version
zsh: command not found: pip3
bjys@localhost ~ % more ~/.zshrc
zsh: command not found: more
bjys@localhost ~ % vim ~/.zshrc
zsh: command not found: vim
bjys@localhost ~ % cat ~/.zshrc
zsh: command not found: cat
bjys@localhost ~ % nano ~/.zshrc
zsh: command not found: nano
bjys@localhost ~ % pwd
/Users/bjys
bjys@localhost ~ % cd ~/
bjys@localhost ~ % ls
zsh: command not found: ls
bjys@localhost ~ % ll
zsh: command not found: ll
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# 解决方案:
在命令行直接输入PATH=/bin:/usr/bin:/usr/local/bin:${PATH}
这种设置将几个常见的二进制文件目录添加到了PATH变量的前面,然后追加了现有的PATH值。这是一个常见的做法,以确保这些目录中的命令能够被优先找到,从而回复了我现有的命令,并且运行其他命令成功。