I'd like to use the Orange package for scientific analysis . Installation on x86_64 Ubuntu 12.04
, with Python 2.7.3
, went well, using sudo easy_install orange
. However, the package doesn't seem to be available for direct use:
11:30:43 leon@t410i:~$ python
Python 2.7.3 (default, Apr 20 2012, 22:39:59)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import orange
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named orange
>>>
However, importing the package while running Python from the appropriate dist-packages subdirectory works fine:
11:34:02 leon@t410i:~$ cd /usr/local/lib/python2.7/dist-packages/Orange-2.5a4-py2.7-linux-x86_64.egg/Orange
11:34:32 leon@t410i:/usr/local/lib/python2.7/dist-packages/Orange-2.5a4-py2.7-linux-x86_64.egg/Orange$ python
Python 2.7.3 (default, Apr 20 2012, 22:39:59)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import orange
>>> orange.__file__
'orange.so'
>>>
What is the problem? Other packages contained within dist-packages work fine when python's invoked from anywhere in the filesystem.
The semantics for importing Orange have changed around version 2.5. If using code written with a previous version, some changes must be made, see http://orange.biolab.si/blog/2011/12/20/orange-25-code-conversion/. Critically, one needs to replace:
import orange
with:
import Orange
(note the capital letter O in the second example).
A side effect is that other sub-modules no longer need to be explicitly imported; a single
import Orange
is enough, instead of e.g.
import orange, orngTest, orngStat, orngTree
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With