rpy2 module not working in Python3.2 - r

I am trying to import the rpy2 (version2.3.4) library into Python (version3.2.3) on a Ubuntu 12.10 machine. The rpy2 documentation says that rpy2 works under all Python 3 versions and I am also finding other topics related to rpy2 and Python3.2 which show that these versions should work together. Anyhow when I try to import a module:
from rpy2 import robjects
the result is this:
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/usr/local/lib/python3.2/dist-packages/rpy2/robjects/__init__.py", line 14, in <module>
import rpy2.rinterface as rinterface
File "/usr/local/lib/python3.2/dist-packages/rpy2/rinterface/__init__.py", line 8, in <module>
raise RuntimeError("Python (>=2.7 and < 3.0) or >=3.3 are required to run rpy2")
RuntimeError: Python (>=2.7 and < 3.0) or >=3.3 are required to run rpy2
So, is rpy2 really not working with Python3.2 what would fit to the information the projects is giving me or waht might be the problem.
thx.

The rpy2 documentation says that rpy2 works under all Python 3 versions
Not quite, I hope; check the part about installing rpy2.
Python 3.2 will probably never be supported by rpy2 (Python 3.2 is already EOL). If your are after using Python 3, update to Python 3.3.

Related

ModuleNotFoundError: No module named 'IPython' on logging the R model

For R model registration from jupyter to azure databricks, I was logging the R model using mlflow,
predictor <- crate(function(x) predict(model,.x))
mlflow_log_model( predictor,'MODEL')< facing error here>
Traceback (most recent call last):
File "/usr/local/anaconda3/envs/r-mlflow-1.26.1/lib/python3.7/site-packages/mlflow/utils/databricks_utils.py", line 44, in _get_dbutils
import IPython
ModuleNotFoundError: No module named 'IPython'
when I try to import IPython module using below code:
from IPython import get_ipython
I got below error:
I installed the IPython module using below command:
pip install ipython
I imported ipython module and run the below code:
import IPython
from IPython import get_ipython
from IPython.display import Image
print(Image)
print(IPython.__version__)
It executed successfully with out any error:

Unable to import google.cloud.vision via the reticulate package in R

I am using the reticulate package to import python modules into RStudio.I was able to import packages like cv2,pandas,sklearn but was unable to import the google.cloud.vision package.I have installed this package via pip and am using Anaconda 4.4.0 Python 2.7 version on ubuntu-trusty-14.04-amd64-server on AWS.Pic of the error in R-Studio Server
The Installation of the vision and the language libraries was done via
pip install --upgrade google-cloud-vision
pip install --upgrade google-cloud-language
I am also able to import these modules in the python interactive sessions without any error
>>>import google.cloud.vision
>>>import google.cloud.language
Can somebody please advise me on what I am doing wrong...
Edit 1 :I have tried using the approach that Yuan Tang had suggested.I have installed the requests and httplib2 package in the conda environment.I have also used the use_python command to point Rstudio to the correct python environment.
use_python("/home/avadhut/miniconda2/bin/python")
The cv2 package is installed in the conda environment and it is imported successfully which means RStudio is using the correct Python environment
Even after doing all this I am getting the following trace-back in the R studio console.
Error in py_module_import(module, convert = convert) :
ImportError: The requests library is not installed, please install the requests package to use the requests transport.
Detailed traceback:
File "/home/avadhut/miniconda2/lib/python2.7/site-packages/google/cloud/vision/__init__.py", line 36, in <module>
from google.cloud.vision.client import Client
File "/home/avadhut/miniconda2/lib/python2.7/site-packages/google/cloud/vision/client.py", line 20, in <module>
from google.cloud.client import ClientWithProject
File "/home/avadhut/miniconda2/lib/python2.7/site-packages/google/cloud/client.py", line 25, in <module>
import google.auth.transport.requests
File "/home/avadhut/miniconda2/lib/python2.7/site-packages/google/auth/transport/requests.py", line 30, in <module>
caught_exc,
File "/home/avadhut/miniconda2/lib/python2.7/site-packages/six.py", line 737, in raise_from
raise value
Here is the pic of my RStudio IDE with the error displayed.
!Reticulate Package Import Error
This is because the Python binary you are using inside RStudio via reticulate does not have those packages (e.g. requests, httplib2, etc) installed.
You can find out what Python reticulate is using via py_config(). You can also find the Python binary you are using on the terminal via which python.
Let's suppose the Python binary you are using on the terminal (the successful imports) is: "/Users/user1/anaconda3/bin/python". Then you use that particular Python binary for reticulate via the following:
use_python("/Users/user1/anaconda3/bin/python")
Then your imports should work as expected.

Building and Installing cx_Oracle with conda skeleton/ conda build not working

I have installed the package cx_Oracle, using conda skeleton command on my Windows 64bits machine, within Anaconda python
conda skeleton pypi cx_Oracle
af5f7daad67d6820670d582dfc045/cx_Oracle-6.0rc1.tar.gz (200 KB) for cx_Oracle.
Downloading cx_Oracle
Using cached download
Unpacking cx_Oracle...
done
when I am checking the file/ directory is finally set, I see it there
File "C:\Anaconda3_version4.3\lib\site-packages\conda_build\skeletons\pypi.py", line 339, in skeletonize
raise RuntimeError("directory already exists: %s" % dir_path)
RuntimeError: directory already exists: .\cx_oracle
but when I am calling it, it cannot be found
import cx_oracle
Traceback (most recent call last):
File "<ipython-input-3-fa7af752f8a0>", line 1, in <module>
import cx_oracle
ModuleNotFoundError: No module named 'cx_oracle'
The directory of cx_Oracle contains the files,
and know I need to build the package with conda build:
conda build cx_Oracle
Just so, it still doesn't work
Provides me the following error:
Anaconda3_version4.3\conda-bld\cx_oracle_1499164
353203\_b_env\Library\include /Tcsrc/cx_Oracle.c /Fobuild\temp.win-amd64-3.6\Rel
ease\src/cx_Oracle.obj -DBUILD_VERSION=6.0rc1
error: command 'cl.exe' failed: No such file or directory
I do not understand what else is needed to finally install the package
Thanks for reading.
Finally, I got a hint about this error thanks to the comments from #darthbith,
Building cx_Oracle requires you to have working C(++) compiler since cx_Oracle is written in C, not in Python even it's a Python module.

PyQt built on Windows: DLL load failed: The specified procedure could not be found

I've tried to build PyQt from sources (with binary Qt 5.8.0 downloaded) on my Windows 7x64.
I did it by this tutorial: https://stackoverflow.com/a/40779370/2726900
I've entered Visual Studio 2015 Command Prompt, activated vcvarsall.bat amd64, activated qtenv2.bat.
Than I configured, built and installed SIP (no errors).
Than I configured PyQt (just added --sip C:/Python35/sip.exe) and successfully built and installed PyQt.
The filed like QtCore.pyi, QtCore.pyd, QtGui.pyi, QtGui.pyd and so on really appeared in my site-packages/PyQt5 folder.
Bug when I tried to import some modules from my installed PyQt5, it failed.
>>> from PyQt5 import QtGui
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: DLL load failed: The specified procedure could not be found.
Cannot you tell me, how can I fix it?
python -m pip install --upgrade pyqt5

Getting matplotlib backends for python 3.6

I installed ipython and matplotlib with pip (9.0.1) under python 3.6 (in Xubuntu 16.04), but no images are showing when I try to plot something.
starting ipython with ipython3 --matplotlib qt gives the following error:
ImportError: Matplotlib qt-based backends require an external PyQt4, PyQt5,
or PySide package to be installed, but it was not found.
I tried to install these with pip, but it fails:
$ pip3.6 install PySide
Collecting PySide
Downloading PySide-1.2.4.tar.gz (9.3MB)
100% |████████████████████████████████| 9.3MB 12.8MB/s
Complete output from command python setup.py egg_info:
only these python versions are supported: [(2, 6), (2, 7), (3, 2), (3, 3), (3, 4)]
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-bzzpzy5q/PySide/
$ pip3.6 install PyQT
Collecting PyQT
Could not find a version that satisfies the requirement PyQT (from versions: )
No matching distribution found for PyQT
$ pip3.6 install PyQT4
Collecting PyQT4
Could not find a version that satisfies the requirement PyQT4 (from versions: )
No matching distribution found for PyQT4
$ pip3.6 install PyQT5
Collecting PyQT5
Could not find a version that satisfies the requirement PyQT5 (from versions: )
No matching distribution found for PyQT5
If I try ipython3 --matplotlib gtk, the error is:
ImportError: Gtk* backend requires pygtk to be installed.
But:
$ pip3.6 install pygtk
Collecting pygtk
Could not find a version that satisfies the requirement pygtk (from versions: )
No matching distribution found for pygtk
I seem to understand that something called PyGobject or PyGI replaced pygtk for python 3. And indeed, ipython3 --matplotlib gtk3 results in:
ImportError: Gtk3 backend requires pygobject to be installed.
But:
$ pip3.6 install pygobject
Collecting pygobject
Could not find a version that satisfies the requirement pygobject (from versions: )
No matching distribution found for pygobject
$ pip3.6 install PyGObject
Collecting PyGObject
Could not find a version that satisfies the requirement PyGObject (from versions: )
No matching distribution found for PyGObject
Finally, pip3.6 install PyGI succeeds!
But matplotlib still complains about GTK things not being installed.
What else should I try?
Getting the Tk backend to work
As #ImportanceOfBeingErnest suggested, at least one backend should be available: the Tk based one.
This is true provided the Tk development libraries were available when python was compiled. This was not the case for me (I suppose a pre-compiled python distribution should be Tk-enabled).
When I tried to start ipython with Tk as matplotlib backend (ipython3 --matplotlib tk), I had an error message similar to the following one:
import _tkinter # If this fails your Python may not be configured for Tk
ImportError: No module named _tkinter
A comment to the following answer explains how to get the Tk development libraries in Ubuntu: apt install tk-dev.
After doing this and recompiling python 3.6, an ipython3 --matplotlib tk session started without errors and could display graphics.
Setting the default backend choice
The matplotlib documentation gives an example of configuration file, which I downloaded as ~/.config/matplotlib/matplotlibrc. In that file I set backend : TkAgg.
Other backends
The comments in the above-mentioned configuration file mention the existence of yet another GUI backend based on WX, which, like PyGTK and PyQT, doesn't seem to be installable using pip for python 3.6 as of january 2017 (at least in Linux):
$ pip3.6 install wxpython
Collecting wxpython
Could not find a version that satisfies the requirement wxpython (from versions: )
No matching distribution found for wxpython

Resources