安装python3,在终端中获取命令未找到错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3895756/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-18 13:14:30  来源:igfitidea点击:

Installed python3, getting command not found error in terminal

pythonmacospath

提问by Brettb

I installed python3, I can open idle and it says it is running python3.0.1, but when I enter python3 in the terminal (on OSX) I get an error saying 'command not found'. Entering python gets me the 2.x version that came on the computer. Any advice on how I can access python3 from the terminal?

我安装了python3,我可以打开idle,它说它正在运行python3.0.1,但是当我在终端(在OSX上)输入python3时,我收到一条错误消息,提示“找不到命令”。输入python让我得到了电脑上的2.x版本。关于如何从终端访问 python3 的任何建议?

Thanks

谢谢

回答by Ned Deily

First, don't use Python 3.0.1. It has many problems and was officially retired upon the release of Python 3.1 (currently 3.1.2). You can find the python.org Mac OS X installer for 3.1.2 here. Once it is installed, then you need to ensure that the bindirectory from the 3.1.2 framework (/Library/Frameworks/Python.framework/Versions/3.1/bin) is on your shell search path. You can manually modify an appropriate shell startup file, like .bash_profile. Or just double-click the Update Shell Profile.commandfound in /Applications/Python 3.1. In either case, you will need to open a new terminal window or re-login. Another approach is to install Python 3.1 from MacPortsor another distributor. Also, alpha releases of Python 3.2 are now available from python.org and elsewhere.

首先,不要使用 Python 3.0.1。它有很多问题,并在 Python 3.1(目前为 3.1.2)发布时正式退役。你可以找到3.1.2 python.org Mac OS X安装在这里。安装后,您需要确保bin3.1.2 框架 ( /Library/Frameworks/Python.framework/Versions/3.1/bin)中的目录在您的 shell 搜索路径上。您可以手动修改适当的 shell 启动文件,例如.bash_profile. 或者只需双击Update Shell Profile.command/Applications/Python 3.1. 无论哪种情况,您都需要打开一个新的终端窗口或重新登录。另一种方法是从MacPorts或其他分销商安装 Python 3.1 。此外,Python 3.2 的 alpha 版本现在可以从 python.org 和其他地方获得。