【问题标题】:The error of importing Enthought Package without using Canopy不使用 Canopy 导入 Enthought 包的错误
【发布时间】:2014-02-20 04:47:24
【问题描述】:

我尝试在没有 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

有没有人有使用 Traits、Enthought 包的相关经验,没有 Canopy 或 Ipython?

【问题讨论】:

    标签: python ipython enthought traits canopy


    【解决方案1】:

    安装 ETS 的最佳链接是 http://code.enthought.com/downloads/。如果您不想安装 Canopy,最简单的方法是使用 pip 或 easy_install 从 PyPI 安装 Traits。最手动的方式需要您克隆整个存储库(https://github.com/enthought/traits)并使用

    构建它
    python setup.py develop
    

    这需要一个 C 编译器。下载单个文件并手动放置它们很可能会失败。

    最后一点:enthought 命名空间已被弃用,现在您可以/应该直接导入特征、traitsui 或 chaco,例如:

    from traits.api import HasTraits
    

    希望这会有所帮助。

    【讨论】:

      猜你喜欢
      • 2014-09-18
      • 1970-01-01
      • 1970-01-01
      • 2013-10-01
      • 1970-01-01
      • 2013-11-18
      • 1970-01-01
      • 2015-12-31
      • 1970-01-01
      相关资源
      最近更新 更多