rPython-win icon indicating copy to clipboard operation
rPython-win copied to clipboard

Windows 7 64bit compilation error

Open grandtiger opened this issue 9 years ago • 15 comments

I followed the instruction, but got compilation error on Windows 7 64bit. Has anyone confirmed that rPython works on on 64bit PC with 64bit R? If so, then I must have missed something. Any suggestions on what else I should check?

BTW, I am using Anaconda python 3.4 distribution. My configure.win looks like the following:

#!/bin/sh

echo 'PKG_LIBS=-LC:/Anaconda3/libs -lpython34'  > src/makevars.win
echo 'PKG_CFLAGS=-I"C:/Anaconda3/include"'     >> src/makevars.win

I used RStudio, and here is the commands and outputs:

> library(devtools)
> install("C:/Downloads/rPython")
Installing rPython
"C:/R/R-31~1.2/bin/x64/R" --vanilla CMD INSTALL "C:/Downloads/rPython"  \
  --library="C:/R/R-3.1.2/library" --install-tests 

* installing *source* package 'rPython' ...
** libs
Warning: this package has a non-empty 'configure.win' file,
so building only the main architecture

gcc -m64 -shared -s -static-libgcc -o rPython.dll tmp.def pycall.o -LC:/Anaconda3/libs -lpython34 -Ld:/RCompile/CRANpkg/extralibs64/local/lib/x64 -Ld:/RCompile/CRANpkg/extralibs64/local/lib -LC:/R/R-31~1.2/bin/x64 -lR
c:/rtools/gcc-4.6.3/bin/../lib/gcc/i686-w64-mingw32/4.6.3/../../../../i686-w64-mingw32/bin/ld.exe: i386 architecture of input file `pycall.o' is incompatible with i386:x86-64 output
pycall.o:pycall.c:(.text+0x5): undefined reference to `__imp__Py_Initialize'
pycall.o:pycall.c:(.text+0x1a): undefined reference to `__imp__PyRun_SimpleStringFlags'
pycall.o:pycall.c:(.text+0x31): undefined reference to `__imp__Py_Finalize'
pycall.o:pycall.c:(.text+0x56): undefined reference to `__imp__PyRun_SimpleStringFlags'
pycall.o:pycall.c:(.text+0x8c): undefined reference to `__imp__PyImport_AddModule'
pycall.o:pycall.c:(.text+0x95): undefined reference to `__imp__PyModule_GetDict'
pycall.o:pycall.c:(.text+0xa8): undefined reference to `__imp__PyDict_GetItemString'
pycall.o:pycall.c:(.text+0xbe): undefined reference to `__imp__PyBytes_AsString'
collect2: ld returned 1 exit status
no DLL was created
ERROR: compilation failed for package 'rPython'
* removing 'C:/R/R-3.1.2/library/rPython'
Error: Command failed (1)

Just an update, I tried it on Windows XP 32bit (with Anaconda python 2.7) and the installation was successful. I'll try to run some code and see if everything is working.

> library(devtools)
> install("C:/Downloads/rPython")
Installing rPython
"C:/R/R-31~1.2/bin/i386/R" --vanilla CMD INSTALL "C:/Downloads/rPython"  \
  --library="C:/R/R-3.1.2/library" --install-tests 

* installing *source* package 'rPython' ...
** libs
Warning: this package has a non-empty 'configure.win' file,
so building only the main architecture

gcc -m32 -I"C:/R/R-31~1.2/include" -DNDEBUG     -I"d:/RCompile/CRANpkg/extralibs64/local/include"  -I"C:/Anaconda/include"   -O3 -Wall  -std=gnu99 -mtune=core2 -c pycall.c -o pycall.o
gcc -m32 -shared -s -static-libgcc -o rPython.dll tmp.def pycall.o -LC:/Anaconda/libs -lpython27 -Ld:/RCompile/CRANpkg/extralibs64/local/lib/i386 -Ld:/RCompile/CRANpkg/extralibs64/local/lib -LC:/R/R-31~1.2/bin/i386 -lR
installing to C:/R/R-3.1.2/library/rPython/libs/i386
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (rPython)

grandtiger avatar Feb 25 '15 17:02 grandtiger

I had a look at the problem (not on Windows, but the issue also applies there) and I wrote what I found out at http://www.datanalytics.com/2015/06/22/rpython-anaconda/

The problem seems to be related to whether Anaconda's Python dll are found when you load the package or not.

cjgb avatar Jun 22 '15 19:06 cjgb

I have what appears to be the same problem. Though I tried installing Python 2.7 for 32-bit via Anaconda and pointing the configure.win to that but it still wont work (Same 64 bit PC. That shouldn't be a problem, right? I have both Program Files and Program Files (x86) so I should be able to use python 32-bit?). Any other ideas?

#!/bin/sh

echo 'PKG_LIBS=-LC:/Anaconda/libs -lpython27'  > src/makevars.win
echo 'PKG_CFLAGS=-I"C:/Anaconda/include"'     >> src/makevars.win
> install("C:/Users/Blair/Downloads/rPython")
Installing rPython
"C:/PROGRA~1/R/R-30~1.2/bin/i386/R" --vanilla CMD INSTALL "C:/Users/Blair/Downloads/rPython" --library="C:/Users/Blair/Documents/R/win-library/3.0"  \
  --install-tests 

* installing *source* package 'rPython' ...
** libs
Warning: this package has a non-empty 'configure.win' file,
so building only the main architecture

gcc -m32 -shared -s -static-libgcc -o rPython.dll tmp.def pycall.o -LC:/Anaconda/libs -lpython27 -Ld:/RCompile/CRANpkg/extralibs64/local/lib/i386 -Ld:/RCompile/CRANpkg/extralibs64/local/lib -LC:/PROGRA~1/R/R-30~1.2/bin/i386 -lR
Cannot export py_close: symbol not found
Cannot export py_exec_code: symbol not found
Cannot export py_get_var: symbol not found
Cannot export py_init: symbol not found
c:/rbuildtools/3.1/gcc-4.6.3/bin/../lib/gcc/i686-w64-mingw32/4.6.3/../../../../i686-w64-mingw32/bin/ld.exe: i386:x86-64 architecture of input file `pycall.o' is incompatible with i386 output
pycall.o:pycall.c:(.text+0x6): undefined reference to `_imp_Py_Initialize'
pycall.o:pycall.c:(.text+0xd): undefined reference to `_imp_PyRun_SimpleStringFlags'
pycall.o:pycall.c:(.text+0x33): undefined reference to `_imp_Py_Finalize'
pycall.o:pycall.c:(.text+0x4f): undefined reference to `_imp_PyRun_SimpleStringFlags'
pycall.o:pycall.c:(.text+0x7f): undefined reference to `_imp_PyImport_AddModule'
pycall.o:pycall.c:(.text+0x88): undefined reference to `_imp_PyModule_GetDict'
pycall.o:pycall.c:(.text+0x94): undefined reference to `_imp_PyDict_GetItemString'
pycall.o:pycall.c:(.text+0xa2): undefined reference to `_imp_PyString_AsString'
collect2: ld returned 1 exit status
ERROR: compilation failed for package 'rPython'
* removing 'C:/Users/Blair/Documents/R/win-library/3.0/rPython'
Error: Command failed (1)
> 

Frikster avatar Oct 13 '15 21:10 Frikster

Just tried installing on a windows 10 machine (Rstudio x64 version). My install seems to be failing for a slightly different reason though..

install("C:/Users/bbhus_000/Downloads/rPython") Installing rPython "C:/PROGRA~1/R/R-32~1.1/bin/x64/R" --no-site-file
--no-environ --no-save --no-restore CMD INSTALL
"C:/Users/bbhus_000/Downloads/rPython"
--library="C:/Users/bbhus_000/Documents/R/win-library/3.2"
--install-tests

  • installing source package 'rPython' ... Warning: running command 'sh ./configure.win' had status 127 ERROR: configuration failed for package 'rPython'
  • removing 'C:/Users/bbhus_000/Documents/R/win-library/3.2/rPython' Error: Command failed (1)

bhuston avatar Oct 27 '15 15:10 bhuston

I get the same error as @bhuston on win7x64. My case may be a bit different though as I am trying to use rPython with the Python 2.7 distribution installed by ArcGIS (it is the only python distribution installed on my machine). I will test on my win10x64 machine later to see if the same error occurs.

Really excited about this package, I hope I can get it working---you're doing great work @cjgb!

mkoohafkan avatar Nov 17 '15 00:11 mkoohafkan

trying to install rPython into R 3.1.3, win 7 Pro, Anaconda Python 3.5 i get as far as install("C:/rPython") then this error:

cannot find -lpython35.lib collect2: ld returned 1 exit status no DLL was created ERROR: compilation failed for package 'rPython'

  • removing 'G:/R-3.1.3/library/rPython' Error: Command failed (1)

My configure.win file is: #!/bin/sh

echo 'PKG_LIBS=-LC:\Anaconda3\libs -l python35' > src/makevars.win echo 'PKG_CFLAGS=-I"C:Anaconda3\include"' >> src/makevars.win

I got it to work by changing backslashes to forward slashes like so:

#!/bin/sh

echo 'PKG_LIBS=-LC:/Anaconda3/libs -lpython35' > src/makevars.win echo 'PKG_CFLAGS=-I"C:/Anaconda3/include"' >> src/makevars.win

Hope this helps.

bwanaaa avatar Dec 21 '15 23:12 bwanaaa

I have python27 in win 64bits machine and I get the following: ImportError: No module named site ERROR: loading failed

arielfuentes avatar Dec 31 '15 16:12 arielfuentes

Similar result Win7, Anaconda 2.4.0 (64 bit) Python 2.7.11:


> library(devtools)
> install("C:/Users/jungd/Downloads/rPython")
Installing rPython
Installing 1 package: RJSONIO
package ‘RJSONIO’ successfully unpacked and MD5 sums checked
"C:/PROGRA~1/R/R-32~1.3/bin/x64/R" --no-site-file --no-environ --no-save --no-restore CMD INSTALL "C:/Users/jungd/Downloads/rPython"  \
  --library="C:/Program Files/R/R-3.2.3/library" --install-tests 

* installing *source* package 'rPython' ...
** libs
Warning: this package has a non-empty 'configure.win' file,
so building only the main architecture

gcc -m64 -I"C:/PROGRA~1/R/R-32~1.3/include" -DNDEBUG     -I"d:/RCompile/r-compiling/local/local323/include"  -I"C:/Users/jungd/AppData/Local/Continuum/Anaconda2/include"   -O2 -Wall  -std=gnu99 -mtune=core2 -c pycall.c -o pycall.o
gcc -m64 -shared -s -static-libgcc -o rPython.dll tmp.def pycall.o -LC:/Users/jungd/AppData/Local/Continuum/Anaconda2/libs -lpython27 -Ld:/RCompile/r-compiling/local/local323/lib/x64 -Ld:/RCompile/r-compiling/local/local323/lib -LC:/PROGRA~1/R/R-32~1.3/bin/x64 -lR
installing to C:/Program Files/R/R-3.2.3/library/rPython/libs/x64
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
Error : .onLoad failed in loadNamespace() for 'rPython', details:
  call: inDL(x, as.logical(local), as.logical(now), ...)
  error: unable to load shared object 'C:/Program Files/R/R-3.2.3/library/rPython/libs/x64/rPython.dll':
  LoadLibrary failure:  %1 is not a valid Win32 application.

Error: loading failed
Execution halted
ERROR: loading failed
* removing 'C:/Program Files/R/R-3.2.3/library/rPython'
Error: Command failed (1)

Didn't seem to give any error output from gcc, but there is no rPython folder in C:\Program Files\R\R-3.2.3\library as that "installing to" line claimed.

davidljung avatar Feb 09 '16 21:02 davidljung

I was able to run it on Windows 10 64 bits. I'm using Python27 that I downloaded straight from Python.org.

I have also gotten "ImportError: No module named site ERROR: loading failed".

I solved that creating a system environment variable called PYTHONHOME and set it to the python path (in my case: "c:\Python27"). So I restarted R and ran install(".../rPython") again.

source: http://kb.froglogic.com/pages/viewpage.action?pageId=2457937

isra312 avatar May 16 '16 21:05 isra312

worked well :-)

kishorekumar2127 avatar Jun 08 '16 07:06 kishorekumar2127

Thanks

kishorekumar2127 avatar Jun 08 '16 07:06 kishorekumar2127

I received the same error as grandtiger, and I got around it by installing the 32bit version of r, deleting my rPython directory, and unzipping it again. The install worked properly once I was using 32bit r and 32bit python27.

hephaestus9 avatar Jun 26 '16 12:06 hephaestus9

I am very new to R. I am applying all the step the same but still the same problem. Could u pls help me? I

Installing rPython "C:/PROGRA~1/R/R-34~1.2/bin/x64/R" --no-site-file --no-environ --no-save --no-restore --quiet CMD INSTALL "C:/Users/Necla/Downloads/rPython"
--library="C:/Users/Necla/Documents/R/win-library/3.4" --install-tests

  • installing source package 'rPython' ... ** libs Warning: this package has a non-empty 'configure.win' file, so building only the main architecture

C:/RBuildTools/3.3/mingw_64/bin/gcc -I"C:/PROGRA~1/R/R-34~1.2/include" -DNDEBUG -I"d:/Compiler/gcc-4.9.3/local330/include" -I"C:/Python27/include" -O2 -Wall -std=gnu99 -mtune=core2 -c pycall.c -o pycall.o C:/RBuildTools/3.3/mingw_64/bin/gcc -shared -s -static-libgcc -o rPython.dll tmp.def pycall.o -LC:/python27/libs -lpython27 -Ld:/Compiler/gcc-4.9.3/local330/lib/x64 -Ld:/Compiler/gcc-4.9.3/local330/lib -LC:/PROGRA~1/R/R-34~1.2/bin/x64 -lR C:/RBuildTools/3.3/mingw_64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.3/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/python27/libs/libpython27.a when searching for -lpython27 C:/RBuildTools/3.3/mingw_64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.3/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/python27/libs/python27.lib when searching for -lpython27 C:/RBuildTools/3.3/mingw_64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.3/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/python27/libs\libpython27.a when searching for -lpython27 C:/RBuildTools/3.3/mingw_64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.3/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/python27/libs/libpython27.a when searching for -lpython27 C:/RBuildTools/3.3/mingw_64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.3/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/python27/libs/python27.lib when searching for -lpython27 C:/RBuildTools/3.3/mingw_64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.3/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/python27/libs\python27.lib when searching for -lpython27 C:/RBuildTools/3.3/mingw_64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.3/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lpython27 collect2.exe: error: ld returned 1 exit status no DLL was created ERROR: compilation failed for package 'rPython'

  • removing 'C:/Users/Necla/Documents/R/win-library/3.4/rPython' Error: Command failed (1)

Necla avatar Oct 09 '17 22:10 Necla

@mkoohafkan thank you so so so much!!! it works!

RaoTianlong avatar Dec 21 '17 07:12 RaoTianlong

@Necla I had the same error. I finaly got it working by only installing the 32bit version of R (and same with Python ofc). Hope this helps

mannimann avatar Jan 16 '18 14:01 mannimann

I am experiencing the same error as grandtiger. I use windows 10 64 bits, Python 3.7.6 and R 3.6.1 In the folder "libs" there are 3 files: libpython37.a python3.lib and python37 Which one should I refer to in the configure.win line echo 'PKG_LIBS=-LC:/Anaconda3/libs -lpython34' > src/makevars.win

my line so far looks like this

echo 'PKG_LIBS=-L"C:/Program Files(x86)/Python37-32/libs -libpython37.a"' > src/makevars.win echo 'PKG_CFLAGS=-I"C:/Program Files (x86)/Python37-32/include"' >> src/makevars.win

Note that I had to include a " for the libs path too, otherwise I was getting a different error. Something like unexpected symbol ')"

Does anybody have a solution?

LuigiPon avatar Apr 16 '20 11:04 LuigiPon