0

I'm using python 3.4.3 under ubuntu 14.04 and would like to use call R code to obtain some results. I know the existence of some packages such as pyper and rpy2 but they look compatible only with python2. By typing 'sudo pip3 install rpy2' I get the follow

Exception information:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 122, in main
    status = self.run(options, args)
  File "/usr/lib/python3/dist-packages/pip/commands/install.py", line 283, in run
    requirement_set.install(install_options, global_options, root=options.root_path)
  File "/usr/lib/python3/dist-packages/pip/req.py", line 1436, in install
    requirement.install(install_options, global_options, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/pip/req.py", line 707, in install
    cwd=self.source_dir, filter_stdout=self._filter_install, show_stdout=False)
  File "/usr/lib/python3/dist-packages/pip/util.py", line 715, in call_subprocess
    % (command_desc, proc.returncode, cwd))
pip.exceptions.InstallationError: Command /usr/bin/python3 -c "import setuptools, tokenize;__file__='/tmp/pip_build_user/rpy2/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-8hhbkgev-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_user/rpy2

Is there any way to use R code inside python 3.4.3?

user1403546
  • 1,680
  • 4
  • 22
  • 43
  • Did you try to install rpy2 with a *wheel* from [C. Gohlke website](http://www.lfd.uci.edu/~gohlke/pythonlibs/) ? I guess there is a few more tricks to achieve the installation on windows, see http://stackoverflow.com/a/32983656/5050917 for example. – mgc Aug 09 '16 at 10:42

1 Answers1

0

rpy is in fact compatible with both Python 2 and Python 3. http://rpy2.readthedocs.io/en/version_2.8.x/overview.html#requirements

Requirements

Currently the development is done on UNIX-like operating systems with the following software versions. Those are the recommended versions to run rpy2 with.

  • Python 3.5, with intended compatibility with 2.7 and > 3.3
Jokab
  • 2,939
  • 1
  • 15
  • 26
  • So why the pip install rpy2 works while pip3 install rpy2 doesn't? File "/usr/lib/python3/dist-packages/pip/util.py", line 715, in call_subprocess % (command_desc, proc.returncode, cwd)) pip.exceptions.InstallationError: Command /usr/bin/python3 -c "import setuptools, tokenize;__file__='/tmp/pip_build_user/rpy2/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-8hhbkgev-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_user/rpy2 – user1403546 Aug 09 '16 at 10:15
  • Are you sure it's not installed for Python 3 when you use `pip install rpy2`? Sometimes if a package is compatible with both Python 2 and 3, only using pip install suffices for both versions. – Jokab Aug 09 '16 at 10:44
  • Have you tried compiling binaries manually, *ie* without pip3, or downloading precompiled binaries? I had a similar problem with another package and it turned out something went wrong with a repository. Not so common for big projects, but it happens. – Synedraacus Aug 09 '16 at 10:44