当前位置: 首页 > 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.lryc.cn/news/444078.html

相关文章:

  • NoSql数据库Redis知识点
  • Redis 使用指南
  • c++与cmake:完整的C++项目构建注意事项
  • Linux自主学习篇
  • MQ入门(4)
  • linux下共享内存的3种使用方式
  • 伊丽莎白·赫莉为杂志拍摄一组素颜写真,庆祝自己荣膺全球最性感女人第一名
  • Qt快捷键说明与用法
  • 技术周刊 | TS 5.6、Chrome DevTools 性能面板上新、Vite 6 Beta、Fastify v5、HTTP 新方法 Query
  • 使用Mockito进行单元测试
  • CSS 布局三大样式简单学习
  • 集成运放UA741的原理与应用的探索
  • LeetCode337. 打家劫舍III
  • python基础(二) 包和import
  • 选址模型 | 基于混沌模拟退火粒子群优化算法的电动汽车充电站选址与定容(Matlab)
  • WPF入门教学十 资源与字典
  • Ubuntu20.04配置NVIDIA+CUDA12.2+CUDNN【附所有下载资源】【亲测有效】【非常详细】
  • Golang | Leetcode Golang题解之第424题替换后的最长重复字符
  • 软考高级:系统安全 -区块链特点:去中心化、开放性、自治性、安全性、匿名性
  • Pandas 数据分析入门详解
  • 【网络】高级IO——epoll版本TCP服务器初阶
  • xml中的转义字符
  • Webpack:现代前端项目的强大打包工具
  • 以root用户登陆ubuntu的桌面环境
  • 《系统架构设计师教程(第2版)》第17章-通信系统架构设计理论与实践-04-其他网络架构(存储网络架构、软件定义网络架构)
  • 大话Python|基础语法(上)
  • crosscrossover24支持的游戏有那些
  • 如何免费调用GPT API进行自然语言处理
  • vue无感刷新Token并重新请求
  • C++和OpenGL实现3D游戏编程【连载10】——纹理的半透明显示