Python RX 'from_' not found in 'Observable | Observable'

1.1k views Asked by At

I'm wanting to setup a simple project with RX python. I'm running python 3.

I've setup my project, and ran pip install rx which successfully installed rx. I checked this using pip show rx which printed:

Name: Rx
Version: 1.6.1
Summary: Reactive Extensions (Rx) for Python
Home-page: http://reactivex.io
Author: Dag Brattli
Author-email: [email protected]
License: Apache License
Location: c:\users\info\desktop\projects\tensorflow\venv\lib\site-packages
Requires:
Required-by:

My simple python script looks like:

from rx import Observable

source = Observable.from_(["Alpha", "Beta", "Gamma", "Delta", "Epsilon"])
source.subscribe(lambda value: print("Received {0}".format(value)))

However, I am getting the warning: Cannot find reference 'from_' in 'Observable | Observable'

And at run time the code is bonking out on the line with the method call from_ on it, with the error: TypeError: 'method' object is not subscriptable

Does anyone know what's happening here?

1

There are 1 answers

0
ramns On

I also was confused with many different rx samples for python.

For your situation here is the solution:

from rx import of

source = of(["Alpha", "Beta", "Gamma", "Delta", "Epsilon"])
source.subscribe(lambda value: print("Received {0}".format(value)))

Here is the docs: https://rxpy.readthedocs.io/en/latest/get_started.html

I'm using python 3.6.4 and rxpy 3.0.1

Confusion is that in source code I do "import rx" but docs are talking about RxPy.

But if I do "pip install rxpy" - I get something not right. Only if I do "pip install rx" - I get correct RxPy installed.

Installing RxPy is documented here: https://rxpy.readthedocs.io/en/latest/installation.html