0

我是命令行的新手。我曾经在我的最后一台 MacBook 上安装了 IPython(配置了所有依赖项),这样我就可以单击仪表板上的图标来启动 iPython qtconsole(在终端外壳之外)。

现在,在我的新 MacBook Pro 上,安装所有相同的文件和依赖项后,我得到:

Jacobs-MacBook-Pro:~ Jacob$ ipython qtconsole
Traceback (most recent call last):
  File "/usr/local/bin/ipython", line 8, in <module>
    load_entry_point('ipython==1.0.dev', 'console_scripts', 'ipython')()
  File "/Library/Python/2.7/site-packages/ipython-1.0.dev-py2.7.egg/IPython/frontend/terminal/ipapp.py", line 390, in launch_new_instance
    app.initialize()
  File "<string>", line 2, in initialize
  File "/Library/Python/2.7/site-packages/ipython-1.0.dev-py2.7.egg/IPython/config/application.py", line 84, in catch_config_error
    return method(app, *args, **kwargs)
  File "/Library/Python/2.7/site-packages/ipython-1.0.dev-py2.7.egg/IPython/frontend/terminal/ipapp.py", line 315, in initialize
    super(TerminalIPythonApp, self).initialize(argv)
  File "<string>", line 2, in initialize
  File "/Library/Python/2.7/site-packages/ipython-1.0.dev-py2.7.egg/IPython/config/application.py", line 84, in catch_config_error
    return method(app, *args, **kwargs)
  File "/Library/Python/2.7/site-packages/ipython-1.0.dev-py2.7.egg/IPython/core/application.py", line 323, in initialize
    self.parse_command_line(argv)
  File "/Library/Python/2.7/site-packages/ipython-1.0.dev-py2.7.egg/IPython/frontend/terminal/ipapp.py", line 310, in parse_command_line
    return super(TerminalIPythonApp, self).parse_command_line(argv)
  File "<string>", line 2, in parse_command_line
  File "/Library/Python/2.7/site-packages/ipython-1.0.dev-py2.7.egg/IPython/config/application.py", line 84, in catch_config_error
    return method(app, *args, **kwargs)
  File "/Library/Python/2.7/site-packages/ipython-1.0.dev-py2.7.egg/IPython/config/application.py", line 429, in parse_command_line
    return self.initialize_subcommand(subc, subargv)
  File "<string>", line 2, in initialize_subcommand
  File "/Library/Python/2.7/site-packages/ipython-1.0.dev-py2.7.egg/IPython/config/application.py", line 84, in catch_config_error
    return method(app, *args, **kwargs)
  File "/Library/Python/2.7/site-packages/ipython-1.0.dev-py2.7.egg/IPython/config/application.py", line 361, in initialize_subcommand
    subapp = import_item(subapp)
  File "/Library/Python/2.7/site-packages/ipython-1.0.dev-py2.7.egg/IPython/utils/importstring.py", line 40, in import_item
    module = __import__(package,fromlist=[obj])
  File "/Library/Python/2.7/site-packages/ipython-1.0.dev-py2.7.egg/IPython/frontend/qt/console/qtconsoleapp.py", line 56, in <module>
    from IPython.external.qt import QtCore, QtGui
  File "/Library/Python/2.7/site-packages/ipython-1.0.dev-py2.7.egg/IPython/external/qt.py", line 23, in <module>
    QtCore, QtGui, QtSvg, QT_API = load_qt(api_opts)
  File "/Library/Python/2.7/site-packages/ipython-1.0.dev-py2.7.egg/IPython/external/qt_loaders.py", line 241, in load_qt
    result = loaders[api]()
  File "/Library/Python/2.7/site-packages/ipython-1.0.dev-py2.7.egg/IPython/external/qt_loaders.py", line 171, in import_pyqt4
    from PyQt4 import QtGui, QtCore, QtSvg
ImportError: dlopen(/Library/Python/2.7/site-packages/PyQt4/QtGui.so, 2): Library not loaded: /usr/local/lib/QtGui.framework/Versions/4/QtGui
  Referenced from: /Library/Python/2.7/site-packages/PyQt4/QtGui.so
  Reason: image not found

而且,再次作为新手,我认为部分问题可能取决于输出,这里:

Jacobs-MacBook-Pro:~ Jacob$ brew install qt
Warning: It appears you have MacPorts or Fink installed.
Software installed with other package managers causes known problems for
Homebrew. If a formula fails to build, uninstall MacPorts/Fink and try again.
Warning: qt-4.8.4 already installed, it's just not linked

提前感谢任何提示。如果您需要我运行任何命令(查看更多输出),请告诉我!

4

1 回答 1

2

所以,你有多个 Python 安装,但不确定你有哪一个。

你有 Homebrew 和 MacPorts。

你的 MacPorts 坏了,你不知道如何修复它。

解决这些问题可能并不难,但我认为是时候擦干净石板并重新开始了。


执行此操作的“简单”方法是重新安装操作系统,使用标准的备份和迁移内容来保留您的 Aqua 级应用程序、用户首选项、文档等。但这非常激烈,不应该是必要的。

要手动清理,首先:

  • 卸载 MacPorts
  • brew uninstall $(brew list). 这将删除所有 Homebrew 软件包。您可以unlink代替,但您真的uninstall想在清理完机器后重建它们。
  • sudo rm -rf /Library/Python /Library/Frameworks/Python.framework /usr/local/share/python*. 这消除了大多数第三方 Python 安装。如果你不知道你的来自哪里,那真的是你能做的最好的。

看看剩下的东西/usr/local/bin。各种各样的东西都可以在这里结束,从 Apple 的 Python 安装的脚本到用于 GUI 应用程序(如 TextMate、Aquamacs 或 GitHub)的命令行工具,再到 SDL 或 Qt 二进制安装附带的工具,所以你可能不想把整个东西都抹掉——但你确实想把它全部看一遍。还要看/usr/local/lib/Library/Frameworks

您可能还需要编辑您的~/.profile.etc 文件以撤消您或那些安装程序可能所做的更改,例如添加/opt/local/bin或添加/Library/Frameworks/Python.framework/Versions/2.7/bin到您的PATH. 也可能有变化/etc,但这不太可能(也不太可能导致问题)。

现在运行brew doctor以确保 Homebrew 满意,重新安装任何与 Python 无关的 Homebrew 软件包和所需的二进制安装程序,现在您已准备好正确安装/配置您的 python、PyQt4-or-PySide、iPython 等。以后开心就好(直到明年你买了一台新电脑)。

于 2013-05-15T22:30:25.693 回答