Trying to run rpy2 and my computer says a function doesn't exist

37 Views Asked by At

So, I tried installing rpy2 just today, and until it was about pouring R instructions into robject.r, it was all going well... until I asked him to use the points function.

This was still a test, so I tried keeping it simple, and passed these instructions:

import rpy2
from rpy2 import robjects
from rpy2.objects import r
r('''
plot(0,0,xlim=c(0,2),ylim=c(0,2)
points(1,1)
''')

(It's best to add a time.sleep so the graph isn't immediately destroyed.)

If I execute this, only the plot with the one point (0,0) is returned; the "points" function gets completely skipped.

I also tried this:

r.plot(0,0)
r.points(0.1,0.1)

Again to no avail.

So, by flipping through the documentation, it looks like the problem is I have to specify that the process is interactive (?), by adding a function that updates the code passing through R. So this became:

interactive.process_revents.start()
r.plot(0,0)
r.points(0.1,0.1)
interactive.process_revents.stop()

And then almost as if to mock me the computer spits out the same graph with one point, and gives me as an error "AttributeError: cffi library 'C:\Program Files\R\R-4.0.5\bin\i386\R.dll' has no function, constant or global variable named 'rpy2_runHandlers'.

This is actually a summary and all this ordeal took many more than three attempts, but at this point I though "great, so I just need to feed it this missing function".

And it is nowhere to be found in the documentation - they literally only state that this exists. Far as I understand, it's supposed to already be in the package and yet isn't there.

I have tried for hours and am at a loss now. How can I at least fill this gap?

Possibly important: my Python environment is Pycharm, and the interpreter is Python 3.7. I installed rpy2 through the built-in package installing setting.

0

There are 0 best solutions below