I haven't tested this, but it should be something like: r_exec = os.path.join(r_home, 'bin', 'R') # Changed --------------------------------------- import subprocess rp = subprocess.check_output([r_exec, '--version'], stderr=subprocess.STDOUT).splitlines() rversion = rp[0] #Twist if 'R RHOME' spits out a warning if rversion.startswith("WARNING"): rversion = rp[1] # End of changed section ------------------- m = re.match('^R ([^ ]+) ([^ ]+) .+$', rversion) ...
Thomas On 26 March 2012 07:57, Yuanda Zhu <jianjian.i...@gmail.com> wrote: > Hi Thomas, > > Please excuse my limited knowledge. I do not quite know how to replace it. > Could you please write the full syntax for me? By the way, is this a > compatibility problem between Python 3.2.2 and rpy2? > > Many thanks, > > Y.Z. > On Mon, Mar 26, 2012 at 5:02 AM, Thomas Kluyver <tak...@gmail.com> wrote: >> >> Hi Yuanda, >> >> You should edit setup.py to use subprocess.check_output() instead of >> os.popen3(). Note that it's not a direct replacement - popen3 returns >> a file-like object with a readline method; check_output() returns a >> string (use s.splitlines() to make a list of lines). >> >> For reference, you can see the current code here: >> https://bitbucket.org/lgautier/rpy2/src/f075a4291e9c/setup.py#cl-185 >> >> Thomas >> >> On 25 March 2012 21:54, Yuanda Zhu <jianjian.i...@gmail.com> wrote: >> > Hi Thomas, >> > >> > Here is the traceback: >> > >> > Traceback (most recent call last): >> > File "G:\Backup\Setup\Python\Packages\rpy2-2.2.5\setup.py", line 462, >> > in >> > <module> >> > [os.path.join('doc', 'source', 'rpy2_logo.png')])], >> > File "F:\Python32\lib\distutils\core.py", line 148, in setup >> > dist.run_commands() >> > File "F:\Python32\lib\distutils\dist.py", line 917, in run_commands >> > self.run_command(cmd) >> > File "F:\Python32\lib\distutils\dist.py", line 936, in run_command >> > cmd_obj.run() >> > File "F:\Python32\lib\distutils\command\install.py", line 569, in run >> > self.run_command('build') >> > File "F:\Python32\lib\distutils\cmd.py", line 313, in run_command >> > self.distribution.run_command(command) >> > File "F:\Python32\lib\distutils\dist.py", line 936, in run_command >> > cmd_obj.run() >> > File "F:\Python32\lib\distutils\command\build.py", line 126, in run >> > self.run_command(cmd_name) >> > File "F:\Python32\lib\distutils\cmd.py", line 313, in run_command >> > self.distribution.run_command(command) >> > File "F:\Python32\lib\distutils\dist.py", line 935, in run_command >> > cmd_obj.ensure_finalized() >> > File "F:\Python32\lib\distutils\cmd.py", line 107, in ensure_finalized >> > self.finalize_options() >> > File "G:\Backup\Setup\Python\Packages\rpy2-2.2.5\setup.py", line 144, >> > in >> > finalize_options >> > rversion = get_rversion(r_home) >> > File "G:\Backup\Setup\Python\Packages\rpy2-2.2.5\setup.py", line 180, >> > in >> > get_rversion >> > rp = os.popen3('"'+r_exec+'" --version')[2] >> > AttributeError: 'module' object has no attribute 'popen3' >> > >> > Please help me, thank you very much >> > >> > Y.Z. >> > >> > On Mon, Mar 26, 2012 at 4:24 AM, Yuanda Zhu <jianjian.i...@gmail.com> >> > wrote: >> >> >> >> Hi Niek, >> >> >> >> Here is the Traceback >> >> >> >> >> >> Traceback (most recent call last): >> >> File "G:\Backup\Setup\Python\Packages\rpy2-2.2.5\setup.py", line 462, >> >> in >> >> <module> >> >> [os.path.join('doc', 'source', 'rpy2_logo.png')])], >> >> File "F:\Python32\lib\distutils\core.py", line 148, in setup >> >> dist.run_commands() >> >> File "F:\Python32\lib\distutils\dist.py", line 917, in run_commands >> >> self.run_command(cmd) >> >> File "F:\Python32\lib\distutils\dist.py", line 936, in run_command >> >> cmd_obj.run() >> >> File "F:\Python32\lib\distutils\command\install.py", line 569, in run >> >> self.run_command('build') >> >> File "F:\Python32\lib\distutils\cmd.py", line 313, in run_command >> >> self.distribution.run_command(command) >> >> File "F:\Python32\lib\distutils\dist.py", line 936, in run_command >> >> cmd_obj.run() >> >> File "F:\Python32\lib\distutils\command\build.py", line 126, in run >> >> self.run_command(cmd_name) >> >> File "F:\Python32\lib\distutils\cmd.py", line 313, in run_command >> >> self.distribution.run_command(command) >> >> File "F:\Python32\lib\distutils\dist.py", line 935, in run_command >> >> cmd_obj.ensure_finalized() >> >> File "F:\Python32\lib\distutils\cmd.py", line 107, in >> >> ensure_finalized >> >> self.finalize_options() >> >> File "G:\Backup\Setup\Python\Packages\rpy2-2.2.5\setup.py", line 144, >> >> in >> >> finalize_options >> >> rversion = get_rversion(r_home) >> >> File "G:\Backup\Setup\Python\Packages\rpy2-2.2.5\setup.py", line 180, >> >> in >> >> get_rversion >> >> rp = os.popen3('"'+r_exec+'" --version')[2] >> >> >> >> AttributeError: 'module' object has no attribute 'popen3' >> >> >> >> >> >> Please help me fix this, many thanks. >> >> >> >> Y.Z. >> >> >> >> >> >> On Mon, Mar 26, 2012 at 3:59 AM, Thomas Kluyver <tak...@gmail.com> >> >> wrote: >> >>> >> >>> On 25 March 2012 20:17, Yuanda Zhu <jianjian.i...@gmail.com> wrote: >> >>> > AttributeError:'module' object has no attribute 'popen3' >> >>> >> >>> Can you post the traceback that goes with this? It's most likely a bug >> >>> somewhere, as popen3 calls should be replaced using the subprocess >> >>> module (see >> >>> >> >>> http://docs.python.org/library/subprocess.html#replacing-os-popen-os-popen2-os-popen3). >> >>> >> >>> Thanks, >> >>> Thomas >> >>> >> >>> >> >>> >> >>> ------------------------------------------------------------------------------ >> >>> This SF email is sponsosred by: >> >>> Try Windows Azure free for 90 days Click Here >> >>> http://p.sf.net/sfu/sfd2d-msazure >> >>> _______________________________________________ >> >>> rpy-list mailing list >> >>> rpy-list@lists.sourceforge.net >> >>> https://lists.sourceforge.net/lists/listinfo/rpy-list >> >> >> >> >> > >> > >> > >> > ------------------------------------------------------------------------------ >> > This SF email is sponsosred by: >> > Try Windows Azure free for 90 days Click Here >> > http://p.sf.net/sfu/sfd2d-msazure >> > _______________________________________________ >> > rpy-list mailing list >> > rpy-list@lists.sourceforge.net >> > https://lists.sourceforge.net/lists/listinfo/rpy-list >> > >> >> >> ------------------------------------------------------------------------------ >> This SF email is sponsosred by: >> Try Windows Azure free for 90 days Click Here >> http://p.sf.net/sfu/sfd2d-msazure >> _______________________________________________ >> rpy-list mailing list >> rpy-list@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/rpy-list > > > > ------------------------------------------------------------------------------ > This SF email is sponsosred by: > Try Windows Azure free for 90 days Click Here > http://p.sf.net/sfu/sfd2d-msazure > _______________________________________________ > rpy-list mailing list > rpy-list@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/rpy-list > ------------------------------------------------------------------------------ This SF email is sponsosred by: Try Windows Azure free for 90 days Click Here http://p.sf.net/sfu/sfd2d-msazure _______________________________________________ rpy-list mailing list rpy-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rpy-list