traits.api error in python

无人久伴 提交于 2019-12-10 19:37:41

问题


I downloaded the Enthought Tool Suite through this website: http://code.enthought.com/downloads/.

When I write put this code in the python script:

from traits.api import HasTraits, Str, Int
from traitsui.api import View, Item
from traitsui.menu import OKButton, CancelButton

class SimpleEmployee(HasTraits):
    first_name = Str
    last_name = Str
    department = Str

    employee_number = Str
    salary = Int

view1 = View(Item(name = 'first_name'),
             Item(name = 'last_name'),
             Item(name = 'department'),
             buttons = [OKButton, CancelButton])

sam = SimpleEmployee()
sam.configure_traits(view=view1)

I got an error that says:

"ImportError: No module named traits.api "

How do I remedy this? I don't know what I'm missing. Please help me!


回答1:


If I am not mistaken, you will need to compile the Enthought tool suite after downloading, which is not always easy.

I would suggest that you try installing the Enthought Python distribution Free which you can get here: http://www.enthought.com/products/epd_free.php

That way you should have all the necessary packages installed by default.

EDIT:

If you absolutely want to keep the default python distribution, this guy here has compiled a list of useful python packages with easy windows installers.

Furthermore there are very complete python distributions out there which come with almost all the scientific package you could need: PythonXY (although this is only 32bit), then there is the Continuum Anaconda distribution which has been gaining a lot of ground.



来源:https://stackoverflow.com/questions/12849997/traits-api-error-in-python

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!