当前位置: 首页 > news >正文

【macOS】【zsh报错】zsh: command not found: python

 【macOS】【zsh Error】zsh: command not found: python

本地已经安装了Python,且能在Pycharm中编译Python程序并运行。

但是,在macOS终端,运行Python,报错。

首先要确认你在macOS系统下,是否安装了Python。

如果安装了,还要确认Python名称。

例如,我在终端输入python,报错:zsh: command not found: python。

而实际上,我的Python,安装在路径:/usr/local/bin

且文件名为:Python3.

所以,需要在终端输入:python3,才能正确运行。

----------------------------------------

下面是配置环境变量的步骤:

----------------------------------------

There are a few possible reasons why you might be getting this error:

1. Python is not in your PATH:

  • Check the installation location: 
    Make sure you installed Python to a directory that is in your system's PATH.
    Common locations include /usr/local/bin or /opt/anaconda3/bin.

  • Add the directory to your PATH: 
    If the directory is not in your PATH,
     you can add it by editing your .zshrc or .bash_profile file. 
    For example,
     if Python is installed in /usr/local/bin,
     you would add the following line to your .zshrc file:

    Bash

    export PATH="/usr/local/bin:$PATH"
    

    【Note】:
    Goodmao has successfully completed the Python installation and configured the PATH environment variable.

    vi ~/.bash_profile
    /usr/local/bin 
  • Restart your terminal: 
    After making changes to your .zshrc or .bash_profile file,
     you need to restart your terminal for the changes to take effect.

2. You're using the wrong shell:

  • Make sure you're using the correct shell. 
    If you're using a different shell, such as bash,
     you might need to use a different command to start Python. 
    For example, in bash, you would use python3 instead of python.

3. Python is not installed correctly:

  • If you're still having trouble, it's possible that Python is not installed correctly. 
    Try reinstalling Python or checking the installation logs for any errors.

Here's a summary of the steps you can take to resolve the issue:

  1. Check the installation location: 
    Make sure Python is installed in a directory that is in your PATH.
  2. Add the directory to your PATH: 
    If necessary, add the directory to your .zshrc or .bash_profile file.
  3. Restart your terminal: 
    Restart your terminal for the changes to take effect.
  4. Try using a different shell: 
    If you're using a different shell, try using the appropriate command to start Python.
  5. Reinstall Python: 
    If all else fails, try reinstalling Python.

http://www.mrgr.cn/news/30627.html

相关文章:

  • InternVL 微调实践闯关任务
  • vue3常用的组件间通信
  • python AutoGen接入开源模型xLAM-7b-fc-r,测试function calling的功能
  • springsecurity+jwt实现前后端分离认证授权
  • WPF入门教学六 Grid布局进阶
  • Hive基本原理与数据开发
  • 【隐私计算篇】利用多方安全计算MPC实现VGG16人脸识别隐私计算模型
  • pytorch学习笔记一:作用、安装和基本使用方法、自动求导机制、自制线性回归模型、常见tensor格式、hub模块介绍
  • Python中,你可以使用`scipy.stats`库中的`entropy`函数来计算两个连续变量之间的KL散度
  • 打不开Qtcreator(This application fail to start...........)
  • 速盾:高防cdn效果怎么看出来?
  • 24岁大专—程序员历险记;
  • FlexNet Licensing: not running 问题
  • C++ Primer Plus笔记: 2024.09.20
  • Linux 信号的产生
  • CS61C 2020计算机组成原理Lab03
  • Linux 进程2
  • kubernetes存储之GlusterFS(GlusterFS for Kubernetes Storage)
  • 代码随想录算法训练营第51天 | 岛屿数量、岛屿的最大面积
  • index嵌入vue.js, 包括了vue.js的下载地址