2

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: dag@brattli.net
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?

Thomas Cook
  • 4,371
  • 2
  • 25
  • 42
  • Hello thomas, did you find an answer to your problem?? – rfum Apr 15 '19 at 19:52
  • No rfum I did not. – Thomas Cook Apr 16 '19 at 07:54
  • This is strange I've just tried with a python command line from mac os x it works fine for me. Would you please check you python path by `print (sys.path)` ? Maybe the location printed out is not available to your python environment... – rfum Apr 16 '19 at 08:05
  • I don't have the sam environment at the moment, it's at home. I'll have a look tonight when I get in – Thomas Cook Apr 16 '19 at 08:19

1 Answers1

1

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

ramns
  • 49
  • 5