Orange Forum • View topic - How to use orange as a Python module under OS X?

How to use orange as a Python module under OS X?

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

Postby Mitar » Fri May 02, 2008 12:21

I am preparing more comprehensive manual on how to use Orange on Mac OS X as there are different ways of using it.

The main problem is that on Mac OS X the GUI applications come in bundles and so if we want bundles to be portable we have to put everything needed by the bundle into it. This means that there is also a Python bundled in, Qt ... and everything else.

Because of that you can either use this bundled Orange environment or you can build your own. Building your own requires different dependencies (I recommend that you install them through Fink or MacPorts) but offers you also other libraries and programs you might use.

If you use bundled environment you get everything prepared but you are limited to the libraries which are bundled in (and there are not many to keep bundle size smaller).

It would be best if Apple would offer some package management system on their own so that bundle could traceablly install some console based parts. Thus, I am preparing Fink and MacPorts packages which would at least through them solve this.

If you want to access Python (and thus Orange) in a bundle, run:

Code: Select all
/Applications/Orange.app/Contents/MacOS/python


You can also use this shebang in your scripts to run them under the bundled Python:

Code: Select all
#!/bin/bash /Applications/Orange.app/Contents/MacOS/python

Too bad, I really wanted to use orange for my project

Postby dibau » Mon May 05, 2008 6:57

I must be able to use it from my existing Python app (a Django web app), developed under OS X. I need to use the Python installed on my machine.

When following your suggestion of using the Python bundled with Orange, I get an error:

Code: Select all
>>> import orange
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: dlopen(/Applications/Orange.app/Contents/Resources/orange/orange.so, 2): Symbol not found: _fputs$UNIX2003
  Referenced from: /Applications/Orange.app/Contents/MacOS/../Resources/orange//orange.so
  Expected in: /usr/lib/libSystem.B.dylib

>>>


I'm using OS X 10.4.


:cry:

Re: Too bad, I really wanted to use orange for my project

Postby psmith » Sun Jun 01, 2008 19:07

dibau wrote:I must be able to use it from my existing Python app (a Django web app), developed under OS X. I need to use the Python installed on my machine.

When following your suggestion of using the Python bundled with Orange, I get an error:



I'm doing something very similar. I'd like to use Orange outside the context of the GUI stuff. I tried symlink'ing /Applications/Orange.app/Contents/Resources/orange into my own site-packages, but it didn't like orange.so


Code: Select all
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: dlopen(/opt/local/lib/python2.5/site-packages/orange/orange.so, 2): no suitable image found.  Did find:
   /opt/local/lib/python2.5/site-packages/orange/orange.so: mach-o, but wrong architecture



I'm using Python 2.5.2 in MacOSX 10.5 on an Intel-based machine.


Looking forward to a MacPorts version... good luck! Perhaps there's a case for having a separate MacPorts or source-release version of Orange that doesn't include or require the GUI portions of the application?

Postby JFMuggs » Wed Jul 16, 2008 18:44

I just compiled orange from the svn source for 1.0 according to the ubuntu instructions on my macbook. There are three things to watch out for. First, the mac python framework is in /Library/Frameworks, so you don't want to install everything to /usr/local. I installed to /usr/local/orange/python2.5/site-python/orange, and then threw a symlink from there to /Library/Frameworks/Python.framework/Versions/Current/lib/python2.5/site-packages

Once you have done that, the syntax for the pth file is different from the others I have encountered in the past. I got it to work by creating orange.pth in the framework site-packages directory, with just the word "orange" in it.

Finally, it's important to remember that macs use .dylib and not .so to mark shared libraries. Python can cope with the .so suffix, but you will need to copy liborange.dylib to the installation directory as well as the .so files, and either use a symlink to add this library to /usr/lib, or set DYLD_LIBRARY_PATH (not LD_LIBRARY_PATH) to add the orange install directory to the library search path.

HTH

Postby Mitar » Fri Nov 07, 2008 1:27

We have decided on using Fink package management system for system-wide installation. Scripting on Mac OS X and combining with other programs will thus be much easier. Please read more on download page.

You can still use Python packed in a bundle directly, as described before.

Or you can compile it yourself. Or use distutils. Just be careful as on Mac OS X paths to dynamic libraries used in our modules are hard-coded into them so you will have to change those paths if you move them around. You can use
Code: Select all
install_name_tool
for that. And you can list libraries paths of a module with
Code: Select all
otool -L
.

fink installation on 10.5

Postby PeterW » Tue Dec 23, 2008 18:28

I just installed orange using the new fink installer on 10.5 but when I open up python on try to import orange, python can't find the package. I'm not quite sure what to do next--the fink installation instructions end with fink install orange, which is what I did.

Any thoughts? I'm probably missing something basic here.

Postby Mitar » Wed Dec 24, 2008 5:14

Which Python binary are you executing? System or Fink Python? Because they use different modules and Orange is installed only into Fink Python. To be sure you should run:

Code: Select all
/sw/bin/python2.5

problem with distutils compile, on OSX 10.4.10

Postby rgiuly » Wed Dec 31, 2008 5:15

Hello, I'm having trouble with a distutils compile on OSX. The error message is below. (I'm using the daily snapshot download.) Could someone please help with some advise?

P.S. I'm not able to use fink because not all python packages that I need are available in fink.

P.S. I do not need OrangeCanvas and OrangeWidgets. I just need the "orange" package to work in python.

mac-users-powerbook-g4-37:/Users/macuser/Desktop/orange2 root# python setup.py compile
NOTE: Python Qt not installed, OrangeCanvas and OrangeWidgets will not work.
You can get it at: http://www.riverbankcomputing.co.uk/pyqt/index.php
Sipconfig not found, Qt version could not be found!
PyQwt not installed!
You can get it at: http://pyqwt.sourceforge.net/
Can not determine GCC version!
Orange specific data installation
running compile
Default compiler options are taken...
ld: warning -F: directory name (../../../orange-temp/Orange.app/Contents/Frameworks/) does not exist
ld: warning -F: directory name (../../../orange-temp/Orange.app/Contents/Frameworks/) does not exist
ld: Undefined symbols:
__keymgr_get_and_lock_processwide_ptr
__keymgr_get_and_lock_processwide_ptr_2
__keymgr_set_and_unlock_processwide_ptr

<some of error message omitted>

___sF referenced from Python expected to be defined in /usr/lib/libSystem.B.dylib
_exit referenced from Python expected to be defined in /usr/lib/libSystem.B.dylib

<some of error message omitted>

lipo: can't figure out the architecture type of: /var/tmp//cc3WFGMD.out
make[1]: *** [../../orange.so] Error 1
make: *** [all] Error 1
Compiling... this might take a while, logging into compiling.log... Compiling Orange failed... exiting!
mac-users-powerbook-g4-37:/Users/macuser/Desktop/orange2 root#

Re: problem with distutils compile, on OSX 10.4.10

Postby Mitar » Thu Jan 01, 2009 6:30

rgiuly wrote:Hello, I'm having trouble with a distutils compile on OSX.


Which Mac OS X version do you have?

rgiuly wrote:(I'm using the daily snapshot download.)


Sorry, but what are you using is far from a daily snapshot. It got stuck almost one year ago. I just discovered that. Could you please use SVN and checkout trunk from there until we fix the problem with daily snapshots generation?

rgiuly wrote:P.S. I'm not able to use fink because not all python packages that I need are available in fink.


That is not true. You can use Fink for some libraries and system (or any other Python) for other libraries. You just have to make sure that versions are the same (2.5 for example). And then you can for example with PYTHONPATH variable include other libraries. So you could for example install Orange with Fink and set PYTHONPATH to "/sw/lib/python2.5/site-packages/orange/".

It is the same as if you would compile Orange in some subdirectory of your home directory. You could also then just add that directory to PYTHONPATH.

So please try to use trunk version. I believe you should not have problems. But please report back how it will go in any case.

problem with install on OSX 10.4.10

Postby rgiuly » Sat Jan 03, 2009 5:01

I'm using OS X 10.4.10 on powerpc.



I'm not able to completely checkout with svn. I'm using this command:
svn checkout http://www.ailab.si/svn/orange/trunk
The following error comes up:
...
A trunk/add-ons/Text/doc/modules/bookexcerpts.tab
svn: In directory 'trunk/add-ons/Text/doc/modules'
svn: Can't open file 'trunk/add-ons/Text/doc/modules/.svn/tmp/text-base/books.py.svn-base': No such file or directory



I also tried the fink install for orange-py25, and I'm getting the following error (It seems this is not an intermittent error as it has been occurring for more than one day):
curl: (22) The requested URL returned error: 404
### execution of curl failed, exit code 22
Downloading the file "PyQt-mac-gpl-3.17.4.tar.gz" failed.

(1) Give up
(2) Retry the same mirror

Default answer will be chosen in 120 seconds...
How do you want to proceed? [1]


Any help is appreciated.

-rick

Re: problem with install on OSX 10.4.10

Postby Mitar » Sun Jan 04, 2009 3:34

rgiuly wrote:I'm using OS X 10.4.10 on powerpc.


This should work.

rgiuly wrote:I'm not able to completely checkout with svn. I'm using this command:
svn checkout http://www.ailab.si/svn/orange/trunk


Please do checkout only source (if you are interested only in Python modules as otherwise you will checkout also a whole bunch of other not needed files):

svn checkout http://www.ailab.si/svn/orange/trunk/source

(But yes, there is something wrong with a SVN repository - we will investigate (we just update it when we develop, we almost never checkout it as a whole). Thanks.)

rgiuly wrote:I also tried the fink install for orange-py25, and I'm getting the following error (It seems this is not an intermittent error as it has been occurring for more than one day):


If you are interested only in Pyhon modules and not GUI, then you not need PyQt. So it is strange that it wanted to download PyQt. Have you really tried to install "fink install orange-py25" or have you tried "fink install orange" (which installs also GUI?). I also recommend that you use "fink install orange-svn-py25" which installs daily snapshot version of Orange (and not an old so-called stable 1.0 version).

I really recommend that you always run this script before you try to install any Orange package as our packages are not yet in the official Fink packages tree so they have to be updated manually (with this script). It also setups for you our binary Fink packages repository, but this does nothing for you as it is only for Intel Macs, sorry.

rgiuly wrote:curl: (22) The requested URL returned error: 404
### execution of curl failed, exit code 22
Downloading the file "PyQt-mac-gpl-3.17.4.tar.gz" failed.


This file has been removed from the PyQt developer's site. This is the reason why you cannot access it anymore. They have removed it probably because current version is 3.17.6. If you would use our update script you would get a new Fink package description file which already points to this new version and compilation of PyQt would not fail.

OSX PPC compile

Postby rgiuly » Wed Jan 14, 2009 0:07

Hello again,

I've now tried the following to compile on OSX PPC:
./fink-selfupdate-orange.sh
/sw/bin/fink update-all
/sw/bin/fink install orange-svn-py25

Still no success

Several hours of compiling happened, and then I got the following error:

Code: Select all
...
undefined dynamic_lookup -lstdc++ -L../.. -lorange_include -L/sw/lib -lorange -o ../../orangeom.so
/usr/libexec/gcc/powerpc-apple-darwin8/4.0.1/libtool: can't locate file for: -lorange
/usr/libexec/gcc/powerpc-apple-darwin8/4.0.1/libtool: file: -lorange is not an object file (not allowed in a library)
make[1]: *** [../../orangeom.so] Error 1
make: *** [all] Error 1
### execution of /var/tmp/tmp.1.9XFats failed, exit code 2
Removing runtime build-lock...
Removing build-lock package...
/sw/bin/dpkg-lockwait -r fink-buildlock-orange-svn-0.0.7022-12
(Reading database ... 79424 files and directories currently installed.)
Removing fink-buildlock-orange-svn-0.0.7022-12 ...
Failed: phase compiling: orange-svn-0.0.7022-12 failed

Before reporting any errors, please run "fink selfupdate" and
try again.  If you continue to have issues, please check to see if the
FAQ on fink's website solves the problem.  If not, ask on the fink-users
or fink-beginners mailing lists, with a carbon copy to the maintainer:

        Mitar <mitar@tnode.com>

Note that this is preferable to emailing the maintainer directly, since
most fink package maintainers do not have access to all possible
hardware and software configurations.


Postby Mitar » Thu Jan 15, 2009 0:06

Which version of Xcode do you have installed?

Can you please run:

Code: Select all
fink --log-output build orange-svn-py25


and send me the output? (It will be stored in /tmp/fink-build-log_* file.)

It is strange because from output it looks like it has been building orange-svn package, I am not sure why. (This probably also explains why it has been compiling for so long as there is Qt to compile.)

Can you do:

Code: Select all
fink list --tab orange


and send me the output?

osx installation

Postby sam » Thu Jun 11, 2009 17:21

I do not have any coding background and would like to have a step wise procedure for installing orange on osX 10.4.11

i downloaded the dmg files, mounted them and dragged the orange file to the application folder.

When i try to launch the orange.app....nothing loads.

:(

-S

Postby Mitar » Thu Jun 11, 2009 23:14

Which version have you downloaded? Please try with both, stable and daily-build, preferably with daily-build.

Can you open Console application (it comes with Mac OS X) after Orange fails to start and under "Console Messages" you will see if Orange returned any error and reason why it exited. Can you copy/paste it here?

PreviousNext

Return to Questions & Support



cron