Problem Installing Rpy2 On A Mac Os X 10.5.8
5
4
Entering edit mode
14.1 years ago

Hello,

I've searched far and wide, read a previous question in stackoverflow but cant seem to solve the problem of installing rpy2 on my Mac with OS X 10.5.8.

I have Xcode 3.1.4 installed and R 2.11.1

When I run:

sudo python setup.py build install

I get this:

  running build
    running build_py
    running build_ext
    building 'rpy2.rinterface.rinterface' extension
    gcc-4.0 -fno-strict-aliasing -fno-common -dynamic -arch i386 -arch ppc -arch x86_64 -g -O2 -DNDEBUG -g -O3 -DR_INTERFACE_PTRS=1        -DHAVE_POSIX_SIGJMP=1 -DCSTACK_DEFNS=1 -DRIF_HAS_RSIGHAND=1 -Irpy/rinterface -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/i386 -c rpy/rinterface/rinterface.c -o build/temp.macosx-10.5-fat3-2.7/rpy/rinterface/rinterface.o -F/Library/Frameworks/R.framework/.. -framework R -L/Library/Frameworks/R.framework/Resources/lib/i386 -lRlapack -L/Library/Frameworks/R.framework/Resources/lib/i386 -lRblas
    i686-apple-darwin9-gcc-4.0.1: -lRlapack: linker input file unused because linking not done
    i686-apple-darwin9-gcc-4.0.1: -lRblas: linker input file unused because linking not done
    i686-apple-darwin9-gcc-4.0.1: -lRlapack: linker input file unused because linking not done
    i686-apple-darwin9-gcc-4.0.1: -lRblas: linker input file unused because linking not done
    powerpc-apple-darwin9-gcc-4.0.1: -lRlapack: linker input file unused because linking not done
    powerpc-apple-darwin9-gcc-4.0.1: -lRblas: linker input file unused because linking not done
    gcc-4.0 -arch i386 -arch ppc -arch x86_64 -isysroot / -g -bundle -undefined dynamic_lookup build/temp.macosx-10.5-fat3-2.7/rpy/rinterface/rinterface.o -L-F/Library/Frameworks/R.framework/.. -L-framework -LR -L/Library/Frameworks/R.framework/Resources/modules -L-F/Library/Frameworks/R.framework/.. -L-framework -LR  L/Library/Frameworks/R.framework/Resources/modules -lR -o build/lib.macosx-10.5-fat3-2.7/rpy2/rinterface/rinterface.so
    ld: library not found for -lR
    ld: library not found for -lR
    collect2: ld returned 1 exit status
    ldcollect2: : library ld returned 1 exit status
    not found for -lR
    collect2: ld returned 1 exit status
    lipo: can't open input file: /var/tmp//ccFngK8H.out (No such file or directory)
    error: command 'gcc-4.0' failed with exit status 1

Edit:

Tried Michael Dondrup's suggestions:

sudo python setup.py build --r-home /Library/Frameworks/R.framework/Versions/2.11/Resources install

and got this Error:

running build
running build_py
running build_ext
building 'rpy2.rinterface.rinterface' extension
gcc-4.0 -fno-strict-aliasing -fno-common -dynamic -arch i386 -arch ppc -arch x86_64 -g -O2 -DNDEBUG -g -O3 -DR_INTERFACE_PTRS=1 -DHAVE_POSIX_SIGJMP=1 -DCSTACK_DEFNS=1 -DRIF_HAS_RSIGHAND=1 -Irpy/rinterface -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/i386 -c rpy/rinterface/rinterface.c -o build/temp.macosx-10.5-fat3-2.7/rpy/rinterface/rinterface.o -F/Library/Frameworks/R.framework/.. -framework R -L/Library/Frameworks/R.framework/Resources/lib/i386 -lRlapack -L/Library/Frameworks/R.framework/Resources/lib/i386 -lRblas
i686-apple-darwin9-gcc-4.0.1: -lRlapack: linker input file unused because linking not done
i686-apple-darwin9-gcc-4.0.1: -lRblas: linker input file unused because linking not done
i686-apple-darwin9-gcc-4.0.1: -lRlapack: linker input file unused because linking not done
i686-apple-darwin9-gcc-4.0.1: -lRblas: linker input file unused because linking not done
powerpc-apple-darwin9-gcc-4.0.1: -lRlapack: linker input file unused because linking not done
powerpc-apple-darwin9-gcc-4.0.1: -lRblas: linker input file unused because linking not done
gcc-4.0 -arch i386 -arch ppc -arch x86_64 -isysroot / -g -bundle -undefined dynamic_lookup build/temp.macosx-10.5-fat3-2.7/rpy/rinterface/rinterface.o -L-F/Library/Frameworks/R.framework/.. -L-framework -LR -L/Library/Frameworks/R.framework/Versions/2.11/Resources/modules -L-F/Library/Frameworks/R.framework/.. -L-framework -LR -L/Library/Frameworks/R.framework/Versions/2.11/Resources/modules -lR -o build/lib.macosx-10.5-fat3-2.7/rpy2/rinterface/rinterface.so
ld: library not found for -lR
collect2: ld returned 1 exit statusld
: library not found for -lR
collect2: ld: library not found for -lR
ld returned 1 exit status
collect2: ld returned 1 exit status
lipo: can't open input file: /var/tmp//ccet5GLC.out (No such file or directory)
error: command 'gcc-4.0' failed with exit status 1

As Laurent Gautier suggested I tried installing rpy2 2.1.6 and 2.2.0 future version.

Got a very long error list, an excerpt:

running build
running build_py
running build_ext
Configuration for R as a library:
  include_dirs: ('/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/i386',)
  libraries: ('Rblas', 'Rlapack')
  library_dirs: ('/Library/Frameworks/R.framework/Resources/lib/i386',)
  extra_link_args: ('-framework R', '-F/Library/Frameworks/R.framework/..')
 # OSX-specific (included in extra_link_args)
  framework_dirs: ()
  frameworks: ()
building 'rpy2.rinterface.rinterface' extension
gcc-4.0 -fno-strict-aliasing -fno-common -dynamic -arch i386 -arch ppc -arch x86_64 -g -O2 -DNDEBUG -g -O3 -DR_INTERFACE_PTRS=1 -DHAVE_POSIX_SIGJMP=1 -DCSTACK_DEFNS=1 -DRIF_HAS_RSIGHAND=1 -I./rpy/rinterface -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/i386 -c ./rpy/rinterface/rinterface.c -o build/temp.macosx-10.5-fat3-2.7/./rpy/rinterface/rinterface.o
./rpy/rinterface/rinterface.c:61:15: error: R.h: No such file or directory
./rpy/rinterface/rinterface.c:62:24: error: Rinternals.h: No such file or directory
./rpy/rinterface/rinterface.c:63:22: error: Rdefines.h: No such file or directory
./rpy/rinterface/rinterface.c:65:24: error: Rinterface.h: No such file or directory
./rpy/rinterface/rinterface.c:66:27: error: R_ext/Complex.h: No such file or directory
./rpy/rinterface/rinterface.c:67:23: error: Rembedded.h: No such file or directory
./rpy/rinterface/rinterface.c:70:29: error: R_ext/eventloop.h: No such file or directory
./rpy/rinterface/rinterface.c:74:28: error: R_ext/Rdynload.h: No such file or directory
./rpy/rinterface/rinterface.c:75:28: error: R_ext/RStartup.h: No such file or directory
In file included from ./rpy/rinterface/rinterface.c:92:
./rpy/rinterface/rpy_rinterface.h:36: error: syntax error before 'SEXP'
./rpy/rinterface/rpy_rinterface.h:36: warning: no semicolon at end of struct or union
./rpy/rinterface/rpy_rinterface.h:37: warning: data definition has no type or storage class
./rpy/rinterface/rpy_rinterface.h:42: error: syntax error before 'SexpObject'
./rpy/rinterface/rpy_rinterface.h:42: warning: no semicolon at end of struct or union
./rpy/rinterface/rpy_rinterface.h:44: warning: data definition has no type or storage class
In file included from ./rpy/rinterface/rinterface.c:96:
./rpy/rinterface/r_utils.h:6: error: syntax error before 'rpy_findFun'
./rpy/rinterface/r_utils.h:6: error: syntax error before 'symbol'
./rpy/rinterface/r_utils.h:6: warning: data definition has no type or storage class
./rpy/rinterface/r_utils.h:8: error: syntax error before 'rpy_serialize'
./rpy/rinterface/r_utils.h:8: error: syntax error before 'object'
./rpy/rinterface/r_utils.h:8: warning: data definition has no type or storage class
./rpy/rinterface/r_utils.h:9: error: syntax error before 'rpy_unserialize'
./rpy/rinterface/r_utils.h:9: error: syntax error before 'connection'
./rpy/rinterface/r_utils.h:9: warning: data definition has no type or storage class
In file included from ./rpy/rinterface/rinterface.c:98:
./rpy/rinterface/array.h:9: error: syntax error before '*' token
In file included from ./rpy/rinterface/rinterface.c:100:
./rpy/rinterface/rexternalptr.h:8: error: syntax error before 'R_PyObject_decref'
./rpy/rinterface/rexternalptr.h:8: error: syntax error before 's'
./rpy/rinterface/rexternalptr.h:8: warning: data definition has no type or storage class
./rpy/rinterface/rinterface.c:102: error: syntax error before '*' token
./rpy/rinterface/rinterface.c:102: error: syntax error before 'sexp'
./rpy/rinterface/rinterface.c:102: warning: data definition has no type or storage class
In file included from ./rpy/rinterface/rinterface.c:105:
./rpy/rinterface/na_values.c: In function 'NAInteger_tp_new':
./rpy/rinterface/na_values.c:232: error: 'NA_INTEGER' undeclared (first use in this function)
./rpy/rinterface/na_values.c:232: error: (Each undeclared identifier is reported only once
./rpy/rinterface/na_values.c:232: error: for each function it appears in.)
./rpy/rinterface/na_values.c: In function 'NALogical_tp_new':
./rpy/rinterface/na_values.c:272: error: 'NA_LOGICAL' undeclared (first use in this function)
./rpy/rinterface/na_values.c: In function 'NAReal_tp_new':./rpy/rinterface/rinterface.c:61:15: error: R.h: No such file or directory
./rpy/rinterface/rinterface.c:62:24: error: Rinternals.h: No such file or directory
./rpy/rinterface/rinterface.c:63:22: error: Rdefines.h: No such file or directory
./rpy/rinterface/rinterface.c:65:24: error: Rinterface.h: No such file or directory
./rpy/rinterface/rinterface.c:66:27: error: R_ext/Complex.h: No such file or directory
./rpy/rinterface/rinterface.c:67:23: error: Rembedded.h: No such file or directory
./rpy/rinterface/rinterface.c:70:29: error: R_ext/eventloop.h: No such file or directory
./rpy/rinterface/rinterface.c:74:28: error: R_ext/Rdynload.h: No such file or directory

Edit:

Tried new installation of R from source and rpy2 from MacPorts as suggested.

Now I'm getting this error (my mac is intel so I find it strange the arch parameter is i386):

:info:build In file included from rpy/rinterface/rinterface.c:74:
:info:build /opt/local/lib/R/include/R_ext/Rdynload.h:26: warning: function declaration isn't a prototype
:info:build In file included from rpy/rinterface/rinterface.c:105:
:info:build rpy/rinterface/sequence.c: In function 'VectorSexp_ass_slice':
:info:build rpy/rinterface/sequence.c:447: warning: unused variable 'sexp_item'
:info:build rpy/rinterface/sequence.c:447: warning: unused variable 'tmp'
:info:build rpy/rinterface/sequence.c:446: warning: unused variable 'vs'
:info:build rpy/rinterface/sequence.c:386: warning: unused variable 'self_typeof'
:info:build rpy/rinterface/rinterface.c: In function 'EmbeddedR_end':
:info:build rpy/rinterface/rinterface.c:1112: warning: unused variable 'str'
:info:build rpy/rinterface/rinterface.c: In function 'EmbeddedR_WriteConsole':
:info:build rpy/rinterface/rinterface.c:288: warning: 'gstate' may be used uninitialized in this function
:info:build rpy/rinterface/rinterface.c: In function 'EmbeddedR_ShowMessage':
:info:build rpy/rinterface/rinterface.c:356: warning: 'gstate' may be used uninitialized in this function
:info:build rpy/rinterface/rinterface.c: In function 'EmbeddedR_ReadConsole':
:info:build rpy/rinterface/rinterface.c:424: warning: 'gstate' may be used uninitialized in this function
:info:build rpy/rinterface/rinterface.c: In function 'EmbeddedR_FlushConsole':
:info:build rpy/rinterface/rinterface.c:524: warning: 'gstate' may be used uninitialized in this function
:info:build rpy/rinterface/rinterface.c: In function 'EmbeddedR_ChooseFile':
:info:build rpy/rinterface/rinterface.c:568: warning: 'gstate' may be used uninitialized in this function
:info:build rpy/rinterface/rinterface.c: In function 'EmbeddedR_ShowFiles':
:info:build rpy/rinterface/rinterface.c:654: warning: 'gstate' may be used uninitialized in this function
:info:build rpy/rinterface/rinterface.c: In function 'EmbeddedR_CleanUp':
:info:build rpy/rinterface/rinterface.c:787: warning: 'gstate' may be used uninitialized in this function
:info:build rpy/rinterface/rinterface.c: At top level:
:info:build rpy/rinterface/rinterface.c:2774: warning: 'externalMethods' defined but not used
:info:build i686-apple-darwin9-gcc-4.0.1: -lR: linker input file unused because linking not done
:info:build i686-apple-darwin9-gcc-4.0.1: -lRlapack: linker input file unused because linking not done
:info:build i686-apple-darwin9-gcc-4.0.1: -lRblas: linker input file unused because linking not done
:info:build /usr/bin/gcc-4.0 -L/opt/local/lib -bundle -undefined dynamic_lookup -arch i386 -arch i386 build/temp.macosx-10.5-i386-2.6/rpy/rinterface/rinterface.o -L/opt/local/lib/R/lib -L/opt/local/lib/R/modules -lR -o build/lib.macosx-10.5-i386-2.6/rpy2/rinterface/rinterface.so
:info:build ld: library not found for -lR
:info:build collect2: ld returned 1 exit status
:info:build error: command '/usr/bin/gcc-4.0' failed with exit status 1
:info:build shell command " cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_python_py26-rpy2/work/rpy2-2.1.4" && /opt/local/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6 setup.py --no-user-cfg build " returned error 1
:error:build Target org.macports.build returned: shell command failed
:debug:build Backtrace: shell command failed
    while executing
"command_exec build"
    (procedure "portbuild::build_main" line 8)
    invoked from within
"$procedure $targetname"
:info:build Warning: the following items did not execute (for py26-rpy2): org.macports.activate org.macports.build org.macports.destroot org.macports.install
:notice:build Log for py26-rpy2 is at: /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_ports_python_py26-rpy2/main.lo

g

Sorry for the long posts and mess...

Any help would be greatly appreciated.

r python • 11k views
ADD COMMENT
0
Entering edit mode

Also don't:

sudo python setup.py build install

Try python setup.py build first then sudo install from that directory, more safe and clean

ADD REPLY
0
Entering edit mode

btw, I think the QA format is not so good for this kind of iterative process. Maybe just update the output field with the latest output.

ADD REPLY
0
Entering edit mode

Your output looks exactly the same in both cases. I will maybe check that later.

ADD REPLY
0
Entering edit mode

Checked MacPorts?

ADD REPLY
0
Entering edit mode

I've tried MacPorts in the past. I'm currently updating some of the dependencies and fixing premission. will try clean R and RPY2 install. I'll post an update later.

ADD REPLY
0
Entering edit mode

That looks pretty much like almost the same error. There must be something terribly broken, and that could as well be rpy2 itself. Did you ask the mailing list for help?

ADD REPLY
0
Entering edit mode

not yet. will do that tomorrow.

ADD REPLY
2
Entering edit mode
14.1 years ago
Michael 55k

Hi,

OP reported it works with the latest version, good news! I hope they will update the macport too.

Edit: I think all the different possible system setups make the attempt mentioned below far too difficult to figure out without access to your computer and a lot of try-and-error. But there is a much easier solution for you to just get things running MacPorts Based on the BSD ports system, it is simply terrific. it works that way:

  • Download and install MacPorts from dmg
  • Install the rpy2 port: > sudo port install py26-rpy2 e.g. for python 2.6

Try port search rpy2 to find all options

This will get you all the other dependencies as well. It will also install another R for you in addition to the R you possibly installed from the cran OSX binary, but this is worth getting it running. It is especially good for packages which have a rather broken or "special" build process like rpy2.


edit: looked here?

ADD COMMENT
0
Entering edit mode

thanks for the reply. Edited my Q to the correct version of R. where to I set this path?

ADD REPLY
0
Entering edit mode
export LD_LIBRARY_PATH=/path/to/dylib
export CPP_FLAGS=-I/path/to/header
ADD REPLY
0
Entering edit mode

thanks. Now I'm getting this:

running build
running build_py
running build_ext
building 'rpy2.rinterface.rinterface' extension
gcc-4.0 -fno-strict-aliasing -fno-common -dynamic -arch i386 -arch ppc -arch x86_64 -g -O2 -DNDEBUG -g -O3 -DR_INTERFACE_PTRS=1 -DHAVE_POSIX_SIGJMP=1 -DCSTACK_DEFNS=1 -DRIF_HAS_RSIGHAND=1 -Irpy/rinterface -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/i386 -c rpy/rinterface/rinterface.c -o build/temp.macosx-10.5-fat3-2.7/rpy/rinterface/rinterfa
ADD REPLY
0
Entering edit mode

but this looks good, note when debugging build errors you cannot assume you can catch it with the first attemp. It's a step ahead if you change something and get a different error later ;)

ADD REPLY
0
Entering edit mode

True. mind, this is after about 300 such baby steps :). any idea how to advance to the next error?

ADD REPLY
0
Entering edit mode

I don't see an error message, it looks fine to me....

ADD REPLY
0
Entering edit mode

edited my Q to include the error from a failed attempt to install rpy2 using MacPorts.

ADD REPLY
2
Entering edit mode
14.1 years ago
brentp 24k

not sure how you're building R, but you may need to add the flag:

--enable-R-shlib

to "build the shared/dynamic library 'libR'" when you run configure. on ubuntu systems, i think that is not the default in the package manager so i have to build from source, could be the same things on OSX.

ADD COMMENT
0
Entering edit mode

as far as I can tell from the R documentation this is the default in the OSX source.

ADD REPLY
0
Entering edit mode

you sure about that? maybe we're using "source" differently, but, if you build from source downloaded from an r-project mirror, it's the same for all platforms and the default is not to build the shared lib.

ADD REPLY
0
Entering edit mode

it is hard to tell if it was on or not while building, the mac dmg images from cran contain .dylibs so it should in principle work with them.

ADD REPLY
0
Entering edit mode

@Michael: the OS X builds on CRAN are compiled with --enable-R-shlib.

ADD REPLY
1
Entering edit mode
14.1 years ago

[update]

Working with rpy2 2.1.7.

[as answered on stackoverflow]

Can you try a snapshot from the mercurial repository ? (either branch version_2.1.x - future version 2.1.6 -, or version_2.2.x - future version 2.2.0)

The build procedure has been streamlined and should accomodate better OS X.

[follow-up to you edit]

Near the top of the second output, you can see the configuration information for building against R.

It highlights a problem with the current setup.py as it does not play well with several include directories for R headers.

A (somewhat ugly) fix for you would be to hard-code those two include directories near line 151 in setup.py.

This:

self.include_dirs.extend(config._include_dirs)

Would become:

self.include_dirs.extend(('/Library/Frameworks/R.framework/Resources/include', 
                          '/Library/Frameworks/R.framework/Resources/include/i386'))
ADD COMMENT
0
Entering edit mode

edited my Q to include new set of errors. thanks for the reply.

ADD REPLY
0
Entering edit mode

and so I edited my answer.

ADD REPLY
0
Entering edit mode

I release version 2.1.7, and should be working now.

ADD REPLY
0
Entering edit mode

I released version 2.1.x and should be working now.

ADD REPLY
1
Entering edit mode
14.1 years ago

I have been advised on the rpy mailing list by Laurent Gautier to try and install version 2.1.7 from pypi and it worked!

rpy2 finally installed and working.

it is worth noting though that I have updated several dependencies so this might have facilitated in enabling rpy2 to finally work.

ADD COMMENT
0
Entering edit mode

Nice! I hope they will update the macport too, in order to remove the broken port.

ADD REPLY
0
Entering edit mode
13.8 years ago

It seems that I am still unable to install rpy2, despite the version being above 2.1.7. I have installed R on my mac with homebrew.

R version: 2.12.1 python: 2.6.1

my path is:

/Users/michael/virtualenvs/chipSeq/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/X11/bin

I am attempting to install via easy_install, which is reporting that it is installing rpy2 version 2.1.9. The output from easy_install is:

in string

in string

I don't know why it would be trying to find an empty string in an empty line. Any suggestions would be greatly appreciated. Thank you in advance!

ADD COMMENT

Login before adding your answer.

Traffic: 2718 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6