【问题标题】:PyOpenGl fails import attempting to iterate over NoneTypePyOpenGl 尝试迭代 NoneType 时导入失败
【发布时间】:2017-05-29 11:58:25
【问题描述】:

试图让一个名为 chemlab 的库在 python 3.5 中工作

它需要 PyQT4,它需要 PyOpenGL

所有这些都在 64 位机器上,但一切——从 python 到每个库都是 32 位的(也许这很重要)

初始代码是

from chemlab.graphics.qt import QtViewer
from chemlab.graphics.renderers import PointRenderer
from chemlab.graphics.uis import TextUI

vertices = [[0.0, 0.0, 0.0], [0.0, 1.0, 0.0], [2.0, 0.0, 0.0]]
blue = (0, 255, 255, 255)

colors = [blue, ] * 3

v = QtViewer()

pr = v.add_renderer(PointRenderer, vertices, colors)
tu = v.add_ui(TextUI, 100, 100, 'Hello, world!')

v.run()

调用栈如下

Traceback (most recent call last):
  File "C:/Users/eldar/PycharmProjects/ChemTo3D/Proccessor.py", line 13, in <module> tu = v.add_ui(TextUI, 100, 100, 'Hello, world!')
  File "C:\Users\eldar\AppData\Local\Programs\Python\Python35-32\lib\site-packages\chemlab\graphics\qt\qtviewer.py", line 189, in add_ui
    ui = klass(self.widget, *args, **kwargs)
  File "C:\Users\eldar\AppData\Local\Programs\Python\Python35-32\lib\sitepackages\chemlab\graphics\uis.py", line 120, in __init__
    props = setup_textures()
  File "C:\Users\eldar\AppData\Local\Programs\Python\Python35-32\lib\site-packages\chemlab\graphics\uis.py", line 17, in setup_textures
    ft = ImageFont.truetype(font_name, height)
  File "C:\Users\eldar\AppData\Local\Programs\Python\Python35-32\lib\site-packages\PIL\ImageFont.py", line 238, in truetype
    return FreeTypeFont(font, size, index, encoding)
  File "C:\Users\eldar\AppData\Local\Programs\Python\Python35-32\lib\site-packages\PIL\ImageFont.py", line 127, in __init__
    self.font = core.getfont(font, size, index, encoding)
OSError: cannot open resource
Exception ignored in: <bound method VertexBuffer.__del__ of <chemlab.graphics.buffers.VertexBuffer object at 0x04FF7630>>
Traceback (most recent call last):
  File "C:\Users\eldar\AppData\Local\Programs\Python\Python35-32\lib\site-packages\chemlab\graphics\buffers.py", line 26, in __del__
  File "C:\Users\eldar\AppData\Local\Programs\Python\Python35-32\lib\site-packages\OpenGL\wrapper.py", line 98, in __nonzero__
  File "C:\Users\eldar\AppData\Local\Programs\Python\Python35-32\lib\site-packages\OpenGL\platform\baseplatform.py", line 376, in __nonzero__
  File "C:\Users\eldar\AppData\Local\Programs\Python\Python35-32\lib\site-packages\OpenGL\platform\baseplatform.py", line 381, in load
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 954, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 887, in _find_spec
TypeError: 'NoneType' object is not iterable
Exception ignored in: <bound method VertexBuffer.__del__ of <chemlab.graphics.buffers.VertexBuffer object at 0x04FF7D10>>
Traceback (most recent call last):
  File "C:\Users\eldar\AppData\Local\Programs\Python\Python35-32\lib\site-packages\chemlab\graphics\buffers.py", line 26, in __del__
  File "C:\Users\eldar\AppData\Local\Programs\Python\Python35-32\lib\site-packages\OpenGL\wrapper.py", line 98, in __nonzero__
  File "C:\Users\eldar\AppData\Local\Programs\Python\Python35-32\lib\site-packages\OpenGL\platform\baseplatform.py", line 376, in __nonzero__
  File "C:\Users\eldar\AppData\Local\Programs\Python\Python35-32\lib\site-packages\OpenGL\platform\baseplatform.py", line 381, in load
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 954, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 887, in _find_spec
TypeError: 'NoneType' object is not iterable

编辑:阻止任何内容显示的部分是文本。枕头一点也不好玩。如果没有尝试显示文本,分子确实会显示,所以我不再确定 opengl 导入错误在做什么 - 也许什么都没有,也许着色器不可用。正在调查中。

【问题讨论】:

    标签: python pyqt pyopengl


    【解决方案1】:

    这通常是因为您缺少字体。

    查看 github 上的代码,它正在寻找“Arial.ttf”: https://github.com/chemlab/chemlab/blob/cded640add8322bf315abdb155e2e21d942ae337/chemlab/graphics/uis.py#L14

    【讨论】:

      猜你喜欢
      • 2020-11-19
      • 1970-01-01
      • 1970-01-01
      • 2023-03-26
      • 2017-02-20
      • 1970-01-01
      • 2019-04-16
      • 2019-02-03
      • 2018-08-18
      相关资源
      最近更新 更多