我正在尝试在运行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
在PyCharm中选择/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python
作为我的翻译,这表明我的几个软件包已经过时了。这些过时的包与我运行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并运行port upgrade outdated
,结果为Nothing to upgrade
。
如何从2.7.5更新到2.7.6并更新相关的包?
答案 0 :(得分:2)
问题是,小牛似乎已经破坏了构建python扩展。 mavericks上的python是使用较旧的编译器和较旧的选项构建的。这些选项存储起来供以后用于
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/_sysconfigdata.py
您可以手动编辑此文件以删除错误的编译器选项,或者您可以为您执行此操作:
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