小编Dub*_*box的帖子

Python 错误 - TypeError:_argtypes_ 中的第 1 项按值传递联合,这是不受支持的

我认为这不是一个特定于编程的错误,而是由某些库引起的。

我正在将我的项目转移到一台新电脑,我使用 python 3.7.6 使用 anaconda 等重新设置了该电脑。在旧机器上执行任务工作正常,这里我还使用了 anaconda 和 python 3.7(不确定是否是 3.7.6,但我可以检查这一点,我只是在创建环境 python=3.7 时使用)。

当我现在尝试运行我的程序时,我收到:

Exception in Tkinter callback
Traceback (most recent call last):
...    
TypeError: item 1 in _argtypes_ passes a union by value, which is unsupported.
Run Code Online (Sandbox Code Playgroud)

错误很长,但它是由以下库引起的:调用gym.envs,然后调用一些pyglet.libs

错误的最后一行是

...from pyglet.libs.x11 import xlib
  File "...7/lib/python3.7/site-packages/pyglet/libs/x11/xlib.py", line 2928, in <module>
    XEHeadOfExtensionList.argtypes = [XEDataObject]
Run Code Online (Sandbox Code Playgroud)

感谢您的帮助!我不知道如何解决这个问题,甚至不知道如何开始解决它。

python pyglet tkinter typeerror anaconda

4
推荐指数
1
解决办法
1万
查看次数

布尔值作为索引的 Python 效果 (a[a==0] = 1)

我目前正在实现我在 github 上看到的一些代码。

( https://gist.github.com/karpathy/a4166c7fe253700972fcbc77e4ea32c5 )

这里的兴趣点如下:

def prepro(I):
   """ prepro 210x160x3 uint8 frame into 6400 (80x80) 1D 
   float vector """
   I = I[35:195] # crop
   I = I[::2,::2,0] # downsample by factor of 2
   I[I == 144] = 0 # erase background (background type 1)
   I[I == 109] = 0 # erase background (background type 2)
   I[I != 0] = 1 # everything else (paddles, ball) just set to 1
   return I.astype(np.float).ravel()
Run Code Online (Sandbox Code Playgroud)

作者在这里预处理图像以训练神经网络。我感到困惑的部分是:

I[I == 144] = 0 # …
Run Code Online (Sandbox Code Playgroud)

python arrays indexing numpy boolean-indexing

1
推荐指数
1
解决办法
51
查看次数