Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError (google.protobuf) with rdm_test_server.py #1599

Closed
ssilverman opened this issue Nov 24, 2019 · 17 comments
Closed

ImportError (google.protobuf) with rdm_test_server.py #1599

ssilverman opened this issue Nov 24, 2019 · 17 comments

Comments

@ssilverman
Copy link

ssilverman commented Nov 24, 2019

When I try to run rdm_test_server.py, I get this:

Traceback (most recent call last):
File "/usr/local/bin/rdm_test_server.py", line 38, in
from ola.ClientWrapper import ClientWrapper, SelectServer
File "/usr/local/lib/python2.7/site-packages/ola/ClientWrapper.py", line 28, in
File "/usr/local/lib/python2.7/site-packages/ola/OlaClient.py", line 21, in
File "/usr/local/lib/python2.7/site-packages/ola/rpc/StreamRpcChannel.py", line 20, in
ImportError: No module named google.protobuf

I'm using homebrew to install ola. I've tried reinstalling protobuf and ola, but I get the same error.

System: OSX 10.14.6

@peternewman
Copy link
Member

Hi @ssilverman ,

We are having the same issue too, you can see our progress in #1584 .

We're currently doing:
pip install --user protobuf==3.1.0

I think Homebrew have switched to Python 3 only for Protobuf, see #1538 for our progress on that front.

Although did ./configure succeed for you? It may just be a path issue in that case. Could you post your config.log (probably before trying to re-run it).

@ssilverman
Copy link
Author

ssilverman commented Nov 26, 2019

Before I try anything I'll gladly send you the config.log file, but do you know the path of the one you're looking for?

@peternewman
Copy link
Member

peternewman commented Nov 26, 2019

I don't know specifically, but this looks relevant:
https://apple.stackexchange.com/questions/164525/what-directory-does-homebrew-use-to-build-programs

Other than that, it will likely be in an ola or olad folder if you can find any config.log files on your machine.

@ssilverman
Copy link
Author

ssilverman commented Nov 26, 2019

There's no config.log files that I could find, related to the ola install. After installing ola, however, there's also no configure file. Are you referring to one that comes with a git clone or one that comes with the homebrew install?

@kripton
Copy link
Member

kripton commented Jul 17, 2020

@ssilverman : Could you please retry, now that #1605 has been merged? It might have fixed your issue :)

@peternewman
Copy link
Member

The RDM tests still don't run under Python 3 due to a few outstanding issues @kripton (xrange being one of the easier ones), so while it may have progressed things and #1655 will have done too, the tests themselves still aren't quite there unfortunately.

@brucelowekamp
Copy link
Contributor

brucelowekamp commented Nov 21, 2020 via email

@peternewman
Copy link
Member

Thanks @brucelowekamp . I've also done the print changes in #1685 which I'll merge in as it didn't seem to hurt and seemed to be sufficient to get the compileall stuff to work, although flake8 needs more work, and actually running seems to need more still in some cases.

I went for a slightly different xrange/range solution as in theory it should be more efficient on python2 I think:
https://github.com/OpenLightingProject/ola/pull/1685/files#diff-5b3f8e5df8e5a430e32762b12ed99f846058b721ae6049489f7a6058fbd8f45eR25-R31

@brucelowekamp
Copy link
Contributor

brucelowekamp commented Nov 21, 2020 via email

@peternewman
Copy link
Member

IMHO I would rather change the xranges to range and
from builtins import range
(or just from future import * so no one needs to think about it)

I thought theoretically xrange should be more efficient on Python 2 from my understanding? Although how much difference it makes in say the licence check when it's just four values I don't really know.

From what I can tell builtins isn't core either, compared to future, i.e. it's another dependency?

but if you want to leave the xranges in place, then
from past.builtins import xrange
https://python-future.org/compatible_idioms.html#xrange
I think is preferable.

From my, admittedly very quick look, past.builtins appeared to be a separate module which we're then requiring people to have for compatibility.

IMHO it’s better to use range everywhere b/c you can wind up thinking about
xrange and range as different things, which they are in python 2 but not
python 3 (unless you from past.builtins import range, but let’s not go
there), and it’s better to think about them as the same function and write
python 3 code moving forward.

Yeah I can see the logic behind that, I guess I was initially driven by doing it as a quick win on a few bits of code. I certainly haven't made the whole codebase pass yet. If the performance issue is fairly minor then doing a find/replace of xrange to range seems pretty trivial too.

@brucelowekamp
Copy link
Contributor

brucelowekamp commented Nov 22, 2020 via email

@peternewman peternewman modified the milestones: 0.10.8, 0.10.9 Nov 22, 2020
@ssilverman
Copy link
Author

ssilverman commented Dec 14, 2020

Update (including all the messages in case others search for anything similar): After installing protobuf with pip, I saw this error when trying to run rdm_test_server.py:

Traceback (most recent call last):
  File "/usr/local/bin/rdm_test_server.py", line 43, in <module>
    from ola.testing.rdm import TestDefinitions
  File "/usr/local/lib/python2.7/site-packages/ola/testing/rdm/TestDefinitions.py", line 24, in <module>
  File "/usr/local/lib/python2.7/site-packages/ola/testing/rdm/ResponderTest.py", line 33, in <module>
  File "/usr/local/lib/python2.7/site-packages/ola/testing/rdm/TimingStats.py", line 19, in <module>
  File "/usr/local/lib/python2.7/site-packages/numpy/__init__.py", line 142, in <module>
  File "/usr/local/lib/python2.7/site-packages/numpy/core/__init__.py", line 47, in <module>
ImportError: 

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the multiarray numpy extension module failed.  Most
likely you are trying to import a failed build of numpy.
Here is how to proceed:
- If you're working with a numpy git repository, try `git clean -xdf`
  (removes all files not under version control) and rebuild numpy.
- If you are simply trying to use the numpy version that you have installed:
  your installation is broken - please reinstall numpy.
- If you have already reinstalled and that did not fix the problem, then:
  1. Check that you are using the Python you expect (you're using /usr/local/opt/python@2/bin/python2.7),
     and that you have no directories in your PATH or PYTHONPATH that can
     interfere with the Python and numpy versions you're trying to use.
  2. If (1) looks fine, you can open a new issue at
     https://github.com/numpy/numpy/issues.  Please include details on:
     - how you installed Python
     - how you installed numpy
     - your operating system
     - whether or not you have multiple versions of Python installed
     - if you built from source, your compiler versions and ideally a build log

     Note: this error has many possible causes, so please don't comment on
     an existing issue about this - open a new one instead.

Original error was: No module named _multiarray_umath

I installed numpy again using: pip install --user numpy, and then I saw this error:

Traceback (most recent call last):
  File "/usr/local/bin/rdm_test_server.py", line 1058, in <module>
    main()
  File "/usr/local/bin/rdm_test_server.py", line 1023, in main
    ('pids.proto', 'draft_pids.proto'))
  File "/usr/local/lib/python2.7/site-packages/ola/PidStore.py", line 1214, in GetStore
OSError: [Errno 2] No such file or directory: '/usr/local/Cellar/ola/0.10.7/share/ola/pids'

From brew info ola:

ola: stable 0.10.7 (bottled), HEAD
Open Lighting Architecture for lighting control information
https://www.openlighting.org/ola/
/usr/local/Cellar/ola/0.10.7_5 (462 files, 20.6MB) *
  Poured from bottle on 2020-12-13 at 23:06:34
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/ola.rb
License: GPL-2.0
==> Dependencies
Build: autoconf ✘, automake ✘, libtool ✔, pkg-config ✔
Required: liblo ✔, libmicrohttpd ✔, libusb ✔, numpy ✔, protobuf@3.6 ✔, python@3.9 ✔
==> Options
--HEAD
	Install HEAD version
==> Analytics
install: 43 (30 days), 123 (90 days), 371 (365 days)
install-on-request: 42 (30 days), 120 (90 days), 359 (365 days)
build-error: 0 (30 days)

It looks like the search directory needs to append that "_5"? (A simple ln -s 0.10.7_5 0.10.7 fixed the problem.)

@peternewman
Copy link
Member

I guess the question with performance is whether it matters there. For the
tests, code generators, etc, I would assume not. If some of the rdm code
is used where it matters, might be worth looking at. My impression was
that most of the code was for testing and didn't appear to be performance
sensitive, but you're a better judge of that. I'm amazed at how fast
python is even with stupid array manipulations (I've never switched my code
to numpy) so I would be surprised if it matters.

Yeah we're only using numpy for some stats, not for performance reasons. You're generally right, I'm sure people would like to run tests quickly, especially if they're iterating, but it's only the stuff in the python folder that might be used in a realtime way (e.g. the DMX and RDM manipulation during a show, and generally only the DMX side of that).

As future can be installed with pip, IMHO it's not a concern. It's not
like needing to find an ancient protobuf binary ;) I might have some
slight concern with the fact that while it is still being maintained, it's
obvious no one is aggressively trying to maintain full forward
compatibility in 3.x, but I would assume that's definitely not a concern
with using future (since it really only does something in py2, which isn't
changing) and I doubt it would be a problem with the small set of features
ola might import from past.builtins.

It's not so much pip, it's more that means they all need to be in the various packaging systems people package OLA for.

I think I was using 3.1.0 as it was consistent across the Ubuntu and Mac packages (probably mostly limited by the old Ubuntu version, but we've moved on since then so on the Travis Bionic we're using the built in deb packaged version with Python 2 (and only not on Python 3 as I think the way I'm switching Python misses the links to the relevant dist packages for some reason, probably mixing pip/pyenv and deb).

@peternewman
Copy link
Member

Traceback (most recent call last):
  File "/usr/local/bin/rdm_test_server.py", line 1058, in <module>
    main()
  File "/usr/local/bin/rdm_test_server.py", line 1023, in main
    ('pids.proto', 'draft_pids.proto'))
  File "/usr/local/lib/python2.7/site-packages/ola/PidStore.py", line 1214, in GetStore
OSError: [Errno 2] No such file or directory: '/usr/local/Cellar/ola/0.10.7/share/ola/pids'

From brew info ola:

ola: stable 0.10.7 (bottled), HEAD
Open Lighting Architecture for lighting control information
https://www.openlighting.org/ola/
/usr/local/Cellar/ola/0.10.7_5 (462 files, 20.6MB) *
  Poured from bottle on 2020-12-13 at 23:06:34

It looks like the search directory needs to append that "_5"? (A simple ln -s 0.10.7_5 0.10.7 fixed the problem.)

Good spot @ssilverman . This feels like a bug with Homebrew given that file just contains the contents of piddatadir which itself is just datadir which is just datarootdir which is just prefix/share:
https://github.com/OpenLightingProject/ola/blob/0.10.7/python/ola/Makefile.mk#L52-L53

Possibly it didn't get updated when the bottle got built.

This will go away when this goes in, but just because the variant gets reset:
Homebrew/homebrew-core#65415

Do you want to report this to them given you've got a Mac to test it on. Feel free to @mention me/this in it too.

@peternewman
Copy link
Member

Does the olad web interface work in this setup too? I guess you only tested after adding the symlink.

@peternewman
Copy link
Member

@ssilverman FYI the RDM tests should finally work on Python 3 in #1761 if you want to take a look?

@peternewman
Copy link
Member

Closing this as it should have been resolved by #1761 . Let us know if you find any outstanding RDM Python bugs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants