【问题标题】:PyQt5 fails as "suitable UI Toolkit" for Mayavi with Python 3.6PyQt5 作为 Mayavi 与 Python 3.6 的“合适的 UI 工具包”失败
【发布时间】:2019-09-20 17:26:51
【问题描述】:

我想运行 SfePy 演示,但使用 Mayavi 显示时出现问题。见http://sfepy.org/doc-devel/installation.html#requirements

我已经:

  • 使用conda create --name SfePy36 python=3.6 创建了 anaconda Python 3.6 环境(根据this answer
  • 使用conda install -c conda-forge mayavi安装了mayavi

  • 使用python3 get-pip.py(来自here)安装了pip3

  • 使用pip3 install PyQt5安装PyQt5

我不知道如何独立检查 PyQt5 是否正确安装。如果我重复pip3 install PyQt5,它会告诉我它已经安装,但这并不意味着它已正确完成或位于正确的位置。


当我在下面运行非常简单的 mayavi 测试时,我收到以下错误。

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/david/anaconda3/envs/SfePy36/lib/python3.6/site- packages/mayavi/tools/sources.py", line 1162, in scalar_field
    return tools.add_dataset(data_source.m_data, name, **kwargs)
  File "/Users/david/anaconda3/envs/SfePy36/lib/python3.6/site-packages/mayavi/tools/tools.py", line 91, in add_dataset
engine = _get_engine_from_kwarg(kwargs)
  File "/Users/david/anaconda3/envs/SfePy36/lib/python3.6/site-packages/mayavi/tools/tools.py", line 36, in _get_engine_from_kwarg
    gcf()
  File "/Users/david/anaconda3/envs/SfePy36/lib/python3.6/site-packages/mayavi/tools/figure.py", line 114, in gcf
engine = get_engine()
  File "/Users/david/anaconda3/envs/SfePy36/lib/python3.6/site-packages/mayavi/tools/engine_manager.py", line 92, in get_engine
return self.new_engine()
  File "/Users/david/anaconda3/envs/SfePy36/lib/python3.6/site-packages/mayavi/tools/engine_manager.py", line 137, in new_engine
check_backend()
  File "/Users/david/anaconda3/envs/SfePy36/lib/python3.6/site-packages/mayavi/tools/engine_manager.py", line 40, in check_backend
raise ImportError(msg)
ImportError: Could not import backend for traitsui.  Make sure you
    have a suitable UI toolkit like PyQt/PySide or wxPython
    installed.

简单演示失败(来自here):

from mayavi import mlab
import numpy as np

x, y, z = np.mgrid[-10:10:20j, -10:10:20j, -10:10:20j]
s = np.sin(x*y*z)/(x*y*z)

mlab.pipeline.volume(mlab.pipeline.scalar_field(x,y,z,s))
mlab.show()

【问题讨论】:

    标签: python pyqt pyqt5 mayavi


    【解决方案1】:

    您可能必须使用 wxPython 而不是 PyQt/PySide。看看installation guide,第 2 点。

    【讨论】:

    • 我又安装了。到第一行:from mayavi import mlab 我得到“这个程序需要访问屏幕。请使用 Python 的框架构建运行,并且仅当您在 Mac 的主显示屏上登录时运行。”我不想构建一个框架(甚至不知道那是什么)我只想在一个普通的 anaconda 环境中运行。我在 Mac 笔记本电脑上,只有一个屏幕。
    • 哦!重新阅读您的链接,不,这不是我遵循的程序。我只是followed this。好的,我将从头开始,看看情况如何。谢谢!
    • 好的,越来越近了; from mayavi import mlab 产生WARNING: Imported VTK version (8.2) does not match the one use to build the TVTK classes (6.3). This may cause problems. Please rebuild TVTK. SfePy 现在成功生成了一个空白窗口i.stack.imgur.com/uOrbL.png 和包含“python2.7”的消息File "/Users/david/anaconda3/envs/SfePy36/lib/python2.7/site-packages/tvtk/tvtk_classes.zip/tvtk_classes/havs_volume_mapper.py", line 125, in __init__ AttributeError: 'module' object has no attribute 'vtkHAVSVolumeMapper'所以我认为使用wxpython 仍然存在问题
    • ...但奇怪的是 SfePy 生成了一个图像,耶! i.stack.imgur.com/TRddq.png
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-08-19
    • 2017-10-26
    • 2019-04-18
    • 1970-01-01
    • 2021-08-16
    相关资源
    最近更新 更多