Orange Forum • View topic - [ImportError] Cannot import name orange

[ImportError] Cannot import name orange

A place to ask questions about methods in Orange and how they are used and other general support.

[ImportError] Cannot import name orange

Postby Imory » Wed Mar 28, 2012 5:27

Hi there,

I am trying to build and install Orange on my machine (OS X Snow Leopard). I just successfully installed "qt-mac-opensource-4.8.0", then "sip-4.13.2" and "PyQt-mac-gpl-4.9.1". Building and installation of Orange did not show any error either.

But when I tried to import Orange in Python command line, it showed me the error message below:
>>> import orange
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.6/site-packages/Orange/orng/orange.py", line 1, in <module>
from Orange.orange import *
File "Orange/__init__.py", line 5, in <module>
from . import orange
ImportError: cannot import name orange
>>> import Orange
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "Orange/__init__.py", line 5, in <module>
from . import orange
ImportError: cannot import name orange


Could someone help me analyze what I might miss?
Thanks in advance.

/Imory
Last edited by Imory on Wed Mar 28, 2012 5:31, edited 1 time in total.

Re: [ImportError] Cannot import name orange

Postby Imory » Wed Mar 28, 2012 5:30

I did see this post: viewtopic.php?f=4&t=1479&p=4182, but it is for Windows. Anyone has idea about who to do for 64-bit OS X? Thanks.

Re: [ImportError] Cannot import name orange

Postby Ales » Wed Mar 28, 2012 10:36

Strange. The installation works for me without any problems on Snow Leopard. Which version of orange did you build (the latest from hg or a source package from PyPi)?

Can you run 'file /Library/Python/2.6/site-packages/Orange/orange.so' in the terminal. What does it say (It should be a 3-way Mach-O bundle)?.
Also can you post the full build and install output of setup.py.

Re: [ImportError] Cannot import name orange

Postby Imory » Wed Mar 28, 2012 15:38

Ales,

Thanks for your reply.

It is a 3-way Mach-O bundle:
/Library/Python/2.6/site-packages/Orange/orange.so: Mach-O universal binary with 3 architectures
/Library/Python/2.6/site-packages/Orange/orange.so (for architecture i386): Mach-O bundle i386
/Library/Python/2.6/site-packages/Orange/orange.so (for architecture ppc7400): Mach-O bundle ppc
/Library/Python/2.6/site-packages/Orange/orange.so (for architecture x86_64): Mach-O 64-bit bundle x86_64


I was using the lastest source downloaded from Bitbucket directly as a .zip file.

As for the output of setup.py, I might not provide it as I have closed the window.
I intended to uninstall it and then re-install, but failed to find a way to really "uninstall".

Re: [ImportError] Cannot import name orange

Postby Imory » Wed Mar 28, 2012 16:43

Ales,

As you mentioned "/Library/Python/2.6/site-packages/Orange/orange.so", I realized that it is dynamically linked and I might not have its directory included in my DYLD_LIBRARY_PATH. Therefore, I tried
Code: Select all
export DYLD_LIBRARY_PATH=/Library/Python/2.6/site-packages/Orange:$DYLD_LIBRARY_PATH

and it worked. =)

Thanks again for your help.

Re: [ImportError] Cannot import name orange

Postby Ales » Thu Mar 29, 2012 9:52

But this should not be necessary. Python import functionality should take care of finding and loading the module.

Imory wrote:I intended to uninstall it and then re-install, but failed to find a way to really "uninstall".
There is no official way to uninstall a python package installed with setup.py unless you use pip installer (http://pypi.python.org/pypi/pip/) or 'distribute' (setuptools replacement). However you can just run
Code: Select all
rm -rf /Library/Python/2.6/site-packages/Orange
rm /Library/Python/2.6/site-packages/Orange-orng-modules.pth
rm /usr/local/bin/orange-canvas

That should take care of all installed files

Re: [ImportError] Cannot import name orange

Postby Imory » Thu Mar 29, 2012 16:20

Thanks, Ales. It's good to know.


Return to Questions & Support



cron