首页 > 代码库 > Spyder提示ValueError: API 'QString' has already been set to version 1

Spyder提示ValueError: API 'QString' has already been set to version 1

转载自:http://wuyuans.com/2013/02/spyder-valueerror-api-qstring-has-already-been-set-to-version-1/

在IPython中使用enthought.mayavi正常,但在Spyder中确有问题,提示如下:

ValueError: API ‘QString‘ has already been set to version 1

问题出在import这里,

from enthought.mayavi import mlab

因为Enthought在调用PyQt时使用的是API #2,而Spyder默认使用API #1,把他改为API #2即可。

打开Tools -> Preferences,左边选择Console,右边打开External modules选项卡,在下面找到PyQt,把里面的API selection for QString and QVariant object:改为API #2,确定,再次运行时就正常了。