在 mac 上为 python3 安装 spyder

Installing spyder for python3 on mac

我很沮丧。看来我不明白这个安装的一个非常基本的概念,找不到答案。

正如标题所说,我想在我的 mac 上为 python3 安装 spyder。因为我找不到任何简单的安装,只需点击一些地方。

在 mac python 2.7 已预装,我已经安装了 python3,这非常简单。

所以我开始通过在命令行中键入 sudo easy_install pip 安装 pip。然后我按照 this site 的介绍,它基本上是说输入 pip install -U spyder 导致最后出现错误。我意识到我必须使用 pip3 因为我有两个 python 版本。为什么没有提到这个?!不管怎样,这行得通——至少它没有触发错误。但是,现在我很困惑应用程序在哪里?我现在如何使用 spyder?

感谢任何帮助。

编辑 当我切换到文件夹 bin 时,终端突然响应 spyder3 但结果是

Nathanaels-iMac:bin nathanaelskrepek$ spyder3 
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/qtpy/__init__.py", line 148, in <module>
    from PySide import __version__ as PYSIDE_VERSION  # analysis:ignore
ModuleNotFoundError: No module named 'PySide'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.6/bin/spyder3", line 11, in <module>
    sys.exit(main())
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/spyder/app/start.py", line 144, in main
    from spyder.app import mainwindow
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/spyder/app/mainwindow.py", line 49, in <module>
    requirements.check_qt()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/spyder/requirements.py", line 39, in check_qt
    import qtpy
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/qtpy/__init__.py", line 154, in <module>
    raise PythonQtError('No Qt bindings could be found')
qtpy.PythonQtError: No Qt bindings could be found

(这里是 Spyder 开发人员)

So I started by installing pip by typing sudo easy_install pip in the command line.

请完全避开这条路线。你永远不应该在你的系统中安装东西 Python (尤其是在 macOS 中),因为你可能会冒着完全破坏你的系统的风险。那是因为 Python 被操作系统用来 运行 某些事情,所以最好不要管它。

在 macOS 中安装 Spyder 的最简单方法是 download Anaconda 并安装它。 Anaconda 附带所有 Spyder 依赖项以及最重要的科学 Python 库,随时可用。

其他选项是 Homebrew 或 MacPorts,但 Anaconda 确实是最简单的。

拿但业,

听起来好像你做了正确的事情,但你也做了其他事情。

pip3 install spyder # Installs Spyder for python 3

如果您想知道 Spyder 应用程序在哪里,请使用 which 命令。

which spyder3 # This will give you the path to the application file.

如果您想使用 Spyder,请输入 spyder3,然后输入您要编辑的文件。

spyder3 myfilename.py # Opens (creates if needed) myfilename.py in Spyder.

根据您的问题有多严重,您可能只想重新安装 Spyder,或者您可能想在 mac 上使用 Homebrew 之类的东西清理 python3 安装。

正如您将在 Github 上看到的那样,Anaconda 最近停止了对 Spyder 的财务支持,他们列出了一些替代安装方法,如果您不打算使用 Anaconda 或 PIP,您可能会想使用这些方法。

祝你好运!