python - 在 OSX 上更新 Python 和包

标签 python macos numpy pip updates

我正在尝试更新运行 Mavericks 的 Apple 计算机上的 python 安装。我担心我用自制软件弄坏了东西。

当我尝试制表符补全python时,我得到以下输出:

python            python2.5-config  python2.7         python3-config    pythonw           pythonw2.7
python-config     python2.6         python2.7-config  python3.3         pythonw2.5        pythonw3.3
python2.5         python2.6-config  python3           python3.3-config  pythonw2.6

运行 where python 会产生以下输出 /usr/bin/python。同样,运行 where python3 会产生 /usr/local/bin/python3 ,而 where python3.3 会产生 /usr/local/bin/python3.3.

当我分别运行每个不同的 python 可执行文件时,我得到以下输出:

$ python
Python 2.7.5 (default, Aug 25 2013, 00:04:04)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
$ python3
Python 3.3.5 (default, Mar 17 2014, 21:17:03)
[GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.38)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
$ python3.3
Python 3.3.5 (default, Mar 17 2014, 21:17:03)
[GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.38)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>

在 PyCharm 中,默认可用的解释器路径是:

  • /System/Library/Frameworks/Python.framework/Versions/2.5/bin/python
  • /System/Library/Frameworks/Python.framework/Versions/2.6/bin/python
  • /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python
  • /usr/local/bin/pypy
  • /usr/local/bin/python3
  • /usr/local/bin/python3.3

选择 /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python 作为 PyCharm 中的解释器,显示其中几个包已过时。这些过时的包与我运行 pip list -o 时显示的包相同:

Warning: cannot find svn location for setuptools==0.6c12dev-r88846
bdist-mpkg (Current: 0.4.4 Latest: 0.5.0)
Could not find any downloads that satisfy the requirement bonjour-py
Some externally hosted files were ignored (use --allow-external bonjour-py to allow).
matplotlib (Current: 1.1.1 Latest: 1.3.1)
numpy (Current: 1.6.2 Latest: 1.8.0)
pyOpenSSL (Current: 0.13 Latest: 0.14)
python-dateutil (Current: 1.5 Latest: 2.2)
pytz (Current: 2012d Latest: 2014.1)
scipy (Current: 0.11.0 Latest: 0.13.3)
setuptools (Current: 0.6c12dev-r88846 Latest: 3.3)
Twisted (Current: 12.2.0 Latest: 13.2.0)
xattr (Current: 0.6.4 Latest: 0.7.4)
zope.interface (Current: 3.8.0 Latest: 4.1.0)
pyobjc-core (Current: 2.3.2a0 Latest: 2.5.1)
pyobjc-framework-AddressBook (Current: 2.3.2a0 Latest: 2.5.1)
pyobjc-framework-AppleScriptKit (Current: 2.3.2a0 Latest: 2.5.1)
pyobjc-framework-AppleScriptObjC (Current: 2.3.2a0 Latest: 2.5.1)
pyobjc-framework-Automator (Current: 2.3.2a0 Latest: 2.5.1)
pyobjc-framework-CFNetwork (Current: 2.3.2a0 Latest: 2.5.1)
pyobjc-framework-Cocoa (Current: 2.3.2a0 Latest: 2.5.1)
pyobjc-framework-Collaboration (Current: 2.3.2a0 Latest: 2.5.1)
pyobjc-framework-CoreData (Current: 2.3.2a0 Latest: 2.5.1)
pyobjc-framework-CoreLocation (Current: 2.3.2a0 Latest: 2.5.1)
pyobjc-framework-CoreText (Current: 2.3.2a0 Latest: 2.5.1)
pyobjc-framework-DictionaryServices (Current: 2.3.2a0 Latest: 2.5.1)
pyobjc-framework-ExceptionHandling (Current: 2.3.2a0 Latest: 2.5.1)
pyobjc-framework-FSEvents (Current: 2.3.2a0 Latest: 2.5.1)
pyobjc-framework-InputMethodKit (Current: 2.3.2a0 Latest: 2.5.1)
pyobjc-framework-InstallerPlugins (Current: 2.3.2a0 Latest: 2.5.1)
pyobjc-framework-InstantMessage (Current: 2.3.2a0 Latest: 2.5.1)
pyobjc-framework-InterfaceBuilderKit (Current: 2.3.2a0 Latest: 2.5.1)
pyobjc-framework-LatentSemanticMapping (Current: 2.3.2a0 Latest: 2.5.1)
pyobjc-framework-LaunchServices (Current: 2.3.2a0 Latest: 2.5.1)
pyobjc-framework-Message (Current: 2.3.2a0 Latest: 2.5.1)
pyobjc-framework-OpenDirectory (Current: 2.3.2a0 Latest: 2.5.1)
pyobjc-framework-PreferencePanes (Current: 2.3.2a0 Latest: 2.5.1)
pyobjc-framework-PubSub (Current: 2.3.2a0 Latest: 2.5.1)
pyobjc-framework-QTKit (Current: 2.3.2a0 Latest: 2.5.1)
pyobjc-framework-Quartz (Current: 2.3.2a0 Latest: 2.5.1)
pyobjc-framework-ScreenSaver (Current: 2.3.2a0 Latest: 2.5.1)
pyobjc-framework-ScriptingBridge (Current: 2.3.2a0 Latest: 2.5.1)
pyobjc-framework-SearchKit (Current: 2.3.2a0 Latest: 2.5.1)
pyobjc-framework-ServiceManagement (Current: 2.3.2a0 Latest: 2.5.1)
pyobjc-framework-SyncServices (Current: 2.3.2a0 Latest: 2.5.1)
pyobjc-framework-SystemConfiguration (Current: 2.3.2a0 Latest: 2.5.1)
pyobjc-framework-WebKit (Current: 2.3.2a0 Latest: 2.5.1)
pyobjc-framework-XgridFoundation (Current: 2.3.2a0 Latest: 2.5.1)

尝试通过 PyCharm 更新 numpy 会导致以下错误:

Upgrade packages failed.


The following command was executed:

/Applications/PyCharm CE.app/helpers/packaging_tool.py install --build-dir /private/var/folders/7r/9rtxb7c94bv_k4szp8lnkpmm0000gn/T/pycharm-packaging258144586042338380.tmp -U numpy

The error output of the command:

Storing debug log for failure in /Users/myusername/Library/Logs/pip.log (1)

检查日志文件看来这就是导致失败的原因

clang: error: unknown argument: '-mno-fused-madd' [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
clang: error: unknown argument: '-mno-fused-madd' [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
failure.

当我运行sudo pip install -U numpy时,我得到了与上面相同的错误

根据这些信息,我(希望是正确的)得出结论,我正在尝试更新 Apple 提供的 python,并且 MacPorts 可能更适合解决此任务。我安装了 MacPorts 并运行了端口升级过时,导致无需升级

如何从 2.7.5 更新到 2.7.6 并更新关联的软件包?

最佳答案

问题是 Mavericks 似乎已经破坏了 Python 扩展的构建。 mavericks 上的 python 是使用具有旧选项的旧编译器构建的。这些选项存储在

中供以后使用
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/_sysconfigdata.py

您可以手动编辑此文件以删除错误的编译器选项,也可以让 sed 为您完成此操作:

sed -i 's/-mno-fused-madd//' /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/_sysconfigdata.py

我只在 Python 2.7 系统上测试和使用过它。我不知道这是否适用于您的/usr/local python 版本。使用自制程序或其他程序使用最新的编译器选项重建这些 python 实例可能会更容易。

更新:您可能还更喜欢使用 gcc 而不是 clang。请参阅:https://stackoverflow.com/a/20295014/16998

关于python - 在 OSX 上更新 Python 和包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22469867/

相关文章:

python - 在 OS X 上安装 numpy 时 pip3 找不到 Python.h

python - 在包含数组元素的数据帧上应用 numpy 运算和向量索引的自然方法

python - 当我尝试从 QString 数组创建时,创建 numpy 数组失败

linux - 在 FreeBSD 上测试 D 程序以在 OSX 上编译

python - scipy.interpolate.Rbf() 的插值不准确

python - 沿轴的零垫阵列

python - 带有自定义语法的 Markdown?

python - 实例化后装饰类及其成员

python - Pandas groupby 聚合忽略空白或无值

c++ - C++、Mac OS X 10.6.8 中的串口问题