简体   繁体   English

为什么Mac OS X上的`/ usr / local / bin`中没有Python 2.7命令行工具?

[英]Why aren't the Python 2.7 command-line tools located in `/usr/local/bin` on Mac OS X?

The Python 2.7 installer disk image for Mac OS X ( python-2.7-macosx10.5.dmg ) states: Mac OS X的Python 2.7安装程序磁盘映像( python-2.7-macosx10.5.dmg )状态:

The installer puts the applications in "Python 2.7" in your Applications folder, command-line tools in /usr/local/bin and the underlying machinery in /Library/Frameworks/Python.framework. 安装程序将应用程序放置在“应用程序”文件夹中的“ Python 2.7”中,将命令行工具放置在/ usr / local / bin中,并将基础机械放置在/Library/Frameworks/Python.framework中。

However, after installation there are no Python 2.7 files in /usr/local/bin/ . 但是,安装后, /usr/local/bin/中没有Python 2.7文件。

  • Are others seeing the same behavior? 其他人也看到相同的行为吗?
  • I assume the solution is simply to create the equivalent symbolic links to /usr/local/bin as Python 2.6, or am I overlooking something? 我认为解决方案只是创建与Python 2.6等效的/usr/local/bin符号链接,还是我忽略了什么?

The python.org Python installer for OS X is a meta package with a set of several packages. OS X的python.org Python安装程序是一个元软件包,其中包含几个软件包。 You can see the packages by clicking on the Customize button during the installation process. 您可以在安装过程中单击“ Customize按钮来查看软件包。 The symlinks in /usr/local/bin are installed by the UNIX command-line tools package. /usr/local/bin中的符号链接由UNIX command-line tools软件包安装。 For the 2.7 release, that package is no longer selected by default. 对于2.7版本,默认情况下不再选择该程序包。 You can install it and the symlinks by doing a custom install and selecting that package; 您可以通过自定义安装并选择该软件包来安装它和符号链接。 if you've already installed 2.7, select just that package. 如果您已经安装了2.7,请选择该软件包。

EDIT: That said, it is important to recognize that, with OS X Python framework builds, just having /usr/local/bin in your search path is generally not sufficient. 编辑:也就是说,重要的是要认识到,使用OS X Python框架构建时,仅在搜索路径中具有/usr/local/bin通常是不够的。 The reason for that is that python scripts included in packages are, by default, installed into the bin directory of the Python directory, eg /Library/Frameworks/Python.framework/Versions/2.7/bin . 原因是默认情况下,软件包中包含的python脚本安装在Python目录的bin目录中,例如/Library/Frameworks/Python.framework/Versions/2.7/bin This is true of just about anything that uses Distutils defaults or installation tools that wrap Distutils , like easy_install ( Distribute or setuptools ) or pip . 这几乎适用于所有使用Distutils默认值或包装Distutils安装工具的东西,例如easy_installDistributesetuptools )或pip This is why there is another installer package, Shell profile updater , that is enabled by default and attempts to modify your login profile to put the framework bin directory at the front of your shell search path, PATH . 这就是为什么还有另一个安装程序软件包Shell profile updater ,该软件包软件包默认情况下处于启用状态,并尝试修改您的登录配置文件以将framework框架目录放在shell搜索路径PATH的前面。 If that is done, the symlinks in /usr/local/bin are not required for python2.7 to be invoked. 完成后,调用python2.7不需要/usr/local/bin中的符号链接。

Steven Majewski's comment stating "I believe I had to explicitly select that option ( "install command line tools" ) in the installer" made me think that I overlooked something in the installer. Steven Majewski的评论说:“我相信我必须在安装程序中明确选择该选项(“安装命令行工具”)”,使我认为我忽略了安装程序中的某些内容。 Sure enough, I overlooked the Customize option. 果然,我忽略了“ Customize选项。 See below. 见下文。

Optional Customize Python Install http://img.skitch.com/20100716-ede8ausmtch9cb6g4mqp4hcm84.jpg 可选的自定义Python安装http://img.skitch.com/20100716-ede8ausmtch9cb6g4mqp4hcm84.jpg

Select UNIX Command-Line Tools http://img.skitch.com/20100716-817rjbyikr8c4y88xkfj6qeg1p.jpg 选择UNIX命令行工具http://img.skitch.com/20100716-817rjbyikr8c4y88xkfj6qeg1p.jpg

11:54 jsmith@upsidedown find /usr -name python2.7
11:54 jsmith@upsidedown

Yeah, that sucks. 是的,太烂了。

I'd follow the pattern that the Python 2.6 (and, in my case, 2.5) installer did, and create the symlinks (as you're suspecting). 我将遵循Python 2.6(在我的情况下为2.5)安装程序的模式,并创建符号链接(如您所怀疑)。 The pattern stayed the same, at least: 模式保持不变,至少:

11:57 jsmith@upsidedown /Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
Python 2.7 (r27:82508, Jul  3 2010, 21:12:11) 
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 

Might be worth a bug report against the installer. 可能值得针对安装程序进行错误报告。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 OS X上的/ usr / bin / python vs /opt/local/bin/python2.7 - /usr/bin/python vs /opt/local/bin/python2.7 on OS X 在 Mac 上运行 S3 命令时获取“/usr/local/opt/python/bin/python2.7: bad interpreter: No such file or directo” - Getting "/usr/local/opt/python/bin/python2.7: bad interpreter: No such file or directo" when running S3 command on Mac 在OS X / macOS上意外删除了/ usr / bin / python而不是/ usr / local / bin / python,如何恢复? - Accidentally deleted /usr/bin/python instead of /usr/local/bin/python on OS X/macOS, how to restore? 在 Mac OS 上从 usr/bin 中删除 python - Removing python from usr/bin on Mac OS 自制链接python到/ usr / local / bin /在Mac上 - Homebrew link python to /usr/local/bin/ on Mac 在某些IDE中找不到Mac OS X / bin / bash:python:命令 - Mac OS X /bin/bash: python: command not found in some IDE 如何通过苹果 xcode 命令行工具 (3.8.9) 将 /usr/bin/python3 中的 python 更新到最新版本 - How to update python at /usr/bin/python3 to the latest available via apple xcode command line tools(3.8.9) 为什么os.path.dirname返回/ usr / local / bin而不是python脚本的路径? - Why os.path.dirname returns /usr/local/bin not the python script's path? 为什么软件包没有安装到我的 Mac 上的两个版本 Python(在 /User/name/Library 和 /usr/local/bin 中)? - Why are packages not installing to both versions of Python on my Mac (in /User/name/Library and /usr/local/bin)? 为什么PyCharm在使用Python虚拟环境时在Mac上删除/ usr / local / bin - Why is PyCharm removing /usr/local/bin on a Mac while using a Python virtual environment
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM