我试着在没有iPython,Canopy的情况下使用enthought包。
我下载traits,traitsui,enthought ...等包。但是,当我将文件夹放在/ Lib中时,它会回调ctraits错误。
从https://github.com/enthought/ctraits下载ctraits后,
仍有问题。当我导入enthought.traits.api或trais.api
时错误消息是
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import enthought.traits.api
File "C:\Python27\lib\enthought\traits\api.py", line 3, in <module>
from traits.api import *
File "<pyshell#0>", line 1, in <module>
import enthought.traits.api
File "C:\Python27\lib\enthought\traits\api.py", line 3, in <module>
from traits.api import *
File "C:\Python27\lib\traits\api.py", line 107, in <module>
from traitsui import view_elements
File "C:\Python27\lib\traitsui\view_elements.py", line 201, in <module>
class SearchStackItem ( HasStrictTraits ):
File "C:\Python27\lib\traits\has_traits.py", line 426, in __new__
mhto = MetaHasTraitsObject( cls, class_name, bases, class_dict, False )
File "C:\Python27\lib\traits\has_traits.py", line 497, in __init__
value = _check_trait( value )
File "C:\Python27\lib\traits\has_traits.py", line 340, in _check_trait
return trait.as_ctrait()
File "C:\Python27\lib\traits\trait_handlers.py", line 597, in as_ctrait
trait.set_validate( validate )
File "C:\Python27\lib\traits\ctraits.py", line 714, in set_validate
raise ValueError("The argument must be a tuple or callable")
ValueError: The argument must be a tuple or callable
有没有人有相关经验使用Trait,没有Canopy或Ipython的Enthought包?
答案 0 :(得分:1)
要安装ETS,最佳链接为http://code.enthought.com/downloads/。如果您不想安装Canopy,最简单的方法是使用pip或easy_install从PyPI安装Traits。最常用的方法是克隆整个存储库(https://github.com/enthought/traits)并使用
构建它python setup.py develop
这将需要一个C编译器。下载单个文件并手动放置它们很可能会失败。
最后一点注意:enthought名称空间已被弃用,现在您可以/应该直接导入traits,traitsui或chaco,例如:
from traits.api import HasTraits
希望这有帮助。