美文网首页
macOS报错 zsh: command not found:

macOS报错 zsh: command not found:

作者: 雪贝壳 | 来源:发表于2023-05-08 18:22 被阅读0次

    问题描述:安装完python后,终端输入python命令报错:

    zhjch@zhjchdeMacBook-Pro ~ % python
    zsh: command not found: python
    
    1.配置.zshrc文件
    创建文件
    touch .zshrc
    
    打开文件
    open .zshrc
    
    添加内容至第一行

    source /Users/user_Name/.bash_profile
    (user_Name为自己电脑的用户名)

    然后保存并关闭文件,执行命令
    source .zshrc
    
    2.配置.bash_profile文件
    首先打开.bash_profile文件
    open .bash_profile
    
    添加内容

    后面的路径根据自己安装的python版本来,可以到/Library/Frameworks中查看

    alias python="/Library/Frameworks/Python.framework/Versions/3.10/bin/python3.10"
    
    如果没有.bash_profile文件,先通过下面的命令创建
    touch .bash_profile
    
    执行下面的命令使配置生效
    source .bash_profile
    

    然后再在终端执行python命令,就没有问题了。

    相关文章

      网友评论

          本文标题:macOS报错 zsh: command not found:

          本文链接:https://www.haomeiwen.com/subject/wbelsdtx.html