问题
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