Installing OP25 On Ubuntu 20.04

Status
Not open for further replies.

KF5YU

Member
Joined
Aug 9, 2018
Messages
29
Location
Wherever The RV Is Parked
I successfully installed OP25 on Ubuntu 18.04 and now I'm trying to get OP25 to run on Ubuntu 20.04 LTS.

When I issue the command: ./rx.py --args 'rtl' -N 'LNA:47' -S 2500000 -x 2 -f 858.7375e6 -o 17e3 -q 2

I get : /usr/bin/env: ‘python’: No such file or directory

Any ideas?
 

waterbwuk

Member
Feed Provider
Joined
Jul 8, 2010
Messages
83
The "No module named op25" error is because it wasn't installed properly or it was installed with the wrong version of python. Did you make sure to do make install?

Next, you should re-build op25 and read through the "cmake" part. This will give you information on the version of python that was found and where it is located at. If it is finding the wrong version of python, you will have to override what it is finding. I believe you can force it to use a certain python version using the -DPYTHON_EXECUTABLE flag in conjunction with the cmake command. There are two other flags (-DPYTHON_INCLUDE_DIR, and -DPYTHON_LIBRARY), but I don't believe op25 looks for those: https://github.com/boatbod/op25/blob/master/cmake/Modules/GrPython.cmake#L31

Documentation:
FindPython3 — CMake 3.18.0-rc2 Documentation
https://stackoverflow.com/questions...alled-but-cmake-is-using-older-version-how-do
 

boatbod

Member
Joined
Mar 3, 2007
Messages
3,316
Location
Talbot Co, MD
Solved that problem with "sudo apt-get install python-is-python3".
Now I get " ModuleNotFoundError: No module named 'op25'"
I believe you'll find the issue is that you don't/didn't have python2 installed when you built op25. You might want to nuke the build directory and start over with a cmake to see if it puts it's libraries in the proper place. (There is a shell script ~/op25/rebuild.sh which should do this for you)
 

KF5YU

Member
Joined
Aug 9, 2018
Messages
29
Location
Wherever The RV Is Parked
Reinstalled Ubuntu 20.04
Issued "sudo apt-get install python-is-python2"
Installed OP25 and ran it.
Now I get:
"Traceback (most recent call last):
File "./rx.py", line 34, in <module>
import numpy
ImportError: No module named numpy"
 

KF5YU

Member
Joined
Aug 9, 2018
Messages
29
Location
Wherever The RV Is Parked
From what I can read and understand on the Internet, op25 is not compatible with Ubuntu 20.04. Am I correct in my assumptions? Don't have a problem downgrading to 18.04
 

boatbod

Member
Joined
Mar 3, 2007
Messages
3,316
Location
Talbot Co, MD
Reinstalled Ubuntu 20.04
Issued "sudo apt-get install python-is-python2"
Installed OP25 and ran it.
Now I get:
"Traceback (most recent call last):
File "./rx.py", line 34, in <module>
import numpy
ImportError: No module named numpy"
Your python is missing the numpy module.

From what I can read and understand on the Internet, op25 is not compatible with Ubuntu 20.04. Am I correct in my assumptions? Don't have a problem downgrading to 18.04

Unclear.
op25 has been modified to be python2/python3 agnostic and there are patches to make it gnuradio-3.8 compatible, but I've not personally attempted a 20.04 install yet, so there may be other factors working against you.
 

waterbwuk

Member
Feed Provider
Joined
Jul 8, 2010
Messages
83
Your python is missing the numpy module.



Unclear.
op25 has been modified to be python2/python3 agnostic and there are patches to make it gnuradio-3.8 compatible, but I've not personally attempted a 20.04 install yet, so there may be other factors working against you.

op25 (well your version anyways) works fine on 20.04. In fact, I've gotten it to compile and try to run on MacOS also, but of course there are audio issues I haven't messed with trying to figure out yet.
 

NebraskaCoder

Member
Joined
Oct 26, 2016
Messages
325
Location
Omaha, NE
I've tried previously to get it to work and kept installing all the modules it was asking for. Hell I even tried installing it in a venv environment and it still didn't work. For the time being, until it works on 20.04, my only solution for my laptop was to multi boot. I have Windows, Ubuntu 19.09 (OP25), and Ubuntu 20.04 (other stuff).
 

NebraskaCoder

Member
Joined
Oct 26, 2016
Messages
325
Location
Omaha, NE
op25 (well your version anyways) works fine on 20.04. In fact, I've gotten it to compile and try to run on MacOS also, but of course there are audio issues I haven't messed with trying to figure out yet.
What method did you use to install it? Once installed, I can't get it to run.
 

waterbwuk

Member
Feed Provider
Joined
Jul 8, 2010
Messages
83
What method did you use to install it? Once installed, I can't get it to run.

I don't have Ubuntu installed any more (it was on my Macbook, just formatted it the other day because beta season starts Monday). I just did a typical base clean install of Ubuntu 20.04 and installed from there. You have to be really careful about mixing different python versions and make sure it's all installed properly. I know I used a mix of reading between boatbod's documentation, trunk-recorder, original op25 documentation, and John's Blog. It's just all about getting the correct dependencies installed (and the correct versions, gnuradio can easily make or break everything). I think the only thing I ended up having to do that wasn't documented was go in and change a few lines of code here and there, but I don't remember what. It was nothing complicated if I remember right. One day when I'm bored I may try to throw Ubuntu 20.04 on a VM and see if I can get some instructions put together.
 
Joined
Jul 27, 2020
Messages
117
I just did an install on uBuntu 20.04 and it took two things to fix your problems. The 'numpy' problem was fixed by changing python to python3 in the "rx.py" file. The missing "op25" was fixed by setting the PYTHONPATH variable to /usr/local/lib/python3/dist-packages
 

nothotscott

Newbie
Joined
Dec 25, 2018
Messages
3
I'm having similar issues as @NebraskaCoder with Kubuntu 20.04. I had to change python-waitress to python3-waitress in order for the build to be successful on CMake 3.10.3
I also installed python-is-python3

When executing rx.py in python3, however, I got this error
Code:
Traceback (most recent call last):
  File "rx.py", line 54, in <module>
    import op25
ModuleNotFoundError: No module named 'op25'

I followed @righthalfplane's advice by setting the PYTHONPATH to /usr/local/lib/python3/dist-packages but then I get this error
Code:
Traceback (most recent call last):
  File "./rx.py", line 54, in <module>
    import op25
  File "/usr/local/lib/python3/dist-packages/op25/__init__.py", line 45, in <module>
    from op25_swig import *
ModuleNotFoundError: No module named 'op25_swig'

On my raspberry pi VM, op25 builds(CMake 3.10.3) and rx executes fine with almost no modification (except for python-waitress). Although, there's errors which I reported at https://github.com/boatbod/op25/issues/6#issuecomment-667444129)
 
Joined
Jul 27, 2020
Messages
117
try a

sudo find / -name op25_swig.py

If it finds it add its path to PYTHONPATH

if it does not find it you need to do a -

sudo apt-get install swig

then go to the "build" directory and do a -

sudo make uninstall

Then trash the build directory

then do the -

./install.sh

to build op25 again.
 
Last edited:

boatbod

Member
Joined
Mar 3, 2007
Messages
3,316
Location
Talbot Co, MD
try a

sudo find / -name op25_swig.py

If it finds it add its path to PYTHONPATH

if it does not find it you need to do a -

sudo apt-get install swig

then go to the "build" directory and do a -

sudo make uninstall

Then trash the build directory

then do the -

./install.sh

to build op25 again.
Usually when op25_swig.py is missing it's because it didn't get built because SWIG was not found during the cmake phase of the build. As righthalfplane says, make sure the package is installed prior to the build. You can use the "rebuild.sh" script to force a full rebuild from cmake onward.
 

N6ML

Member
Joined
Sep 26, 2008
Messages
1,274
Down this rabbit-hole myself today. op25_swig.py is there, but python won't find it unless /usr/local/lib/python3/dist-packages/op
25 is in PYTHPONPATH, and I had to add /usr/local/lib/python3/dist-packages/op25_repeater also (as well as /usr/local/lib/python3/dist-packages).

With all that in place, it fails with:


Code:
Traceback (most recent call last):
  File "./rx.py", line 1018, in <module>
    rx = rx_main()
  File "./rx.py", line 930, in __init__
    self.tb = p25_rx_block(self.options)
  File "./rx.py", line 210, in __init__
    self.open_usrp()
  File "./rx.py", line 857, in open_usrp
    self.__set_rx_from_osmosdr()
  File "./rx.py", line 786, in __set_rx_from_osmosdr
    self.__build_graph(self.src, capture_rate)
  File "./rx.py", line 287, in __build_graph
    self.demod = p25_demodulator.p25_demod_cb( input_rate = capture_rate,
  File "/home/imacdonn/op25/op25/gr-op25_repeater/apps/p25_demodulator.py", line 273, in __init__
    p25_demod_base.__init__(self, if_rate=if_rate, symbol_rate=symbol_rate, filter_type=filter_type)
  File "/home/imacdonn/op25/op25/gr-op25_repeater/apps/p25_demodulator.py", line 99, in __init__
    coeffs = op25_c4fm_mod.c4fm_taps(sample_rate=self.if_rate, span=9, generator=op25_c4fm_mod.transfer_function_rx).generate()
  File "tx/op25_c4fm_mod.py", line 146, in generate
    impulse_response = np.fft.fftshift(np.fft.irfft(self.generator(symbol_rate=self.symbol_rate, rate_multiplier=rate_multiplier), self.sample_rate))
  File "<__array_function__ internals>", line 5, in irfft
  File "/usr/lib/python3/dist-packages/numpy/fft/_pocketfft.py", line 474, in irfft
    output = _raw_fft(a, n, axis, True, False, inv_norm)
  File "/usr/lib/python3/dist-packages/numpy/fft/_pocketfft.py", line 72, in _raw_fft
    z = zeros(s, a.dtype.char)
TypeError: 'float' object cannot be interpreted as an integer

Then it gets even more entertaining. waitress has this:

Code:
try:
    import httplib
except ImportError:  # pragma: no cover
    from http import client as httplib

but because there's a http.py in op25/gr-op25_repeater/apps that fails with:

Code:
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/waitress/compat.py", line 119, in <module>
    import httplib
ModuleNotFoundError: No module named 'httplib'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 72, in apport_excepthook
    from apport.fileutils import likely_packaged, get_recent_crashes
  File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
    from apport.report import Report
  File "/usr/lib/python3/dist-packages/apport/report.py", line 21, in <module>
    from urllib.request import urlopen
  File "/usr/lib/python3.8/urllib/request.py", line 88, in <module>
    import http.client
  File "/home/imacdonn/op25/op25/gr-op25_repeater/apps/http.py", line 31, in <module>
    from waitress.server import create_server
  File "/usr/lib/python3/dist-packages/waitress/__init__.py", line 1, in <module>
    from waitress.server import create_server
  File "/usr/lib/python3/dist-packages/waitress/server.py", line 20, in <module>
    from waitress import trigger
  File "/usr/lib/python3/dist-packages/waitress/trigger.py", line 20, in <module>
    from . import wasyncore
  File "/usr/lib/python3/dist-packages/waitress/wasyncore.py", line 54, in <module>
    from . import compat
  File "/usr/lib/python3/dist-packages/waitress/compat.py", line 121, in <module>
    from http import client as httplib
ImportError: cannot import name 'client' from partially initialized module 'http' (most likely due to a circular import) (/home/imacdonn/op25/op25/gr-op25_repeater/apps/http.py)

It's a bit of a mess. Not sure how @righthalfplane is evading these issues......
 

N6ML

Member
Joined
Sep 26, 2008
Messages
1,274
As far as needing to add the op25 and op25_repeater subdirs to the PYTHONPATH goes, I believe that that's because python 3 does not support implicit relative imports, where python 2 did. The line in op25/__init__.py should really be:

Code:
from .op25_swig import *

Where that leading dot makes it "explicit relative". The same goes for op25_repeater/__init__.py
 

KA1RBI

Member
Joined
Aug 15, 2008
Messages
799
Location
Portage Escarpment
but because there's a http.py in op25/gr-op25_repeater/apps that fails with:

quite right. there was a module in op25 named "http" which created conflicts when attempting to use python3.

That's because python3 (unlike python2) has its own module named http. Consequently I renamed it to "http_server.py".

Based on the messages in the crash, looks like these updates haven't hit Graham's (boatbod) repo yet.

In the osmocom repo there is a patch that must be applied to get op25 to build using the python3 runtime.

The same patch also applies changes to build using gnu radio 3.8.

In the event that ubuntu 20 still uses gnu radio 3.7, we'd probably need to split the patch into two,
one for python3 and one for gnu radio 3.8

Along those lines could someone who's running ubuntu 20 please run the following command (after gnuradio has been installed):
Code:
dpkg-query -l  | grep gnuradio
and post the results.

Max
 
Status
Not open for further replies.
Top