Using GNURadio in Python - python-3.x

I am trying to use GNURadio on Python 3.7. I am running on Windows 10 and using Anaconda.
Every time I try to import GNURadio, I get the following
import gnuradio
Traceback (most recent call last):
File "<ipython-input-3-9dfe3f3e2626>", line 1, in <module>
import gnuradio
ModuleNotFoundError: No module named 'gnuradio'
How can I import GNURadio in Python?

GNU Radio 3.7 is not compatible with Python3; end of story. Also, it's GNU Radio's "legacy/maintenance support release series"; don't use if for anything new! (update:) As of spring 2022, GNU Radio 3.7 is end-of-life and should not be used in anything but legacy systems.
GNU Radio 3.8 is compatible with both Py3 and Py2, but the popular GCN development GNU Radio Windows installer is built against Py2, so no, won't work for you either. 3.10 is available, and will be around for quite a while to enjoy. It is easily installable using your current Linux distro's package manager, or anaconda (on Linux, Mac OS X and Windows).
Installation instructions can be found in the GNU Radio wiki.

Related

Why do I get an ImportError for opencv2 when I run on python3.7.3?

I'm trying to import opencv2 using python3.7.3 on Mac OS 10.10 but an ImportError occurs. How should I solve it?
I tried to install opencv3 using pip, pip3, and homebrew. Probably not install right.
import cv2
import numpy as np
import sys
import pytesseract as py
import matplotlib.pyplot as plt
Error
Traceback (most recent call last):
File "/Users/wujian/Desktop/Project/Proj.py", line 1, in <module>
import cv2
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/cv2/__init__.py", line 3, in <module>
from .cv2 import *
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/cv2/cv2.cpython-37m-darwin.so, 2): Symbol not found: _clock_gettime
Referenced from: /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/cv2/.dylibs/libavutil.56.22.100.dylib (which was built for Mac OS X 10.12)
Expected in: /usr/lib/libSystem.B.dylib
in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/cv2/.dylibs/libavutil.56.22.100.dylib
The issue seems to be (oddly) related to your copy of libavutil which is part of ffmpeg.
It's hinted at by this part of the error message:
ImportError: dlopen(/.../cv2/cv2.cpython-37m-darwin.so, 2): Symbol not found: _clock_gettime
Referenced from: /...python3.7/site-packages/cv2/.dylibs/libavutil.56.22.100.dylib (which was built for Mac OS X 10.12)
Installing OpenCV requires ffmpeg. If you installed it via homebrew, it's listed as a dependency.
$ brew info opencv
...
==> Dependencies
Build: cmake ✓, pkg-config ✓
Required: eigen ✓, ffmpeg ✓, glog ✓, ...
Installing ffmpeg will include the libavutil library, which can be checked by downloading pre-built shared libraries or by Homebrew:
$ brew list ffmpeg | grep libavutil.*dylib
/usr/local/Cellar/ffmpeg/4.1.4_1/lib/libavutil.56.22.100.dylib
/usr/local/Cellar/ffmpeg/4.1.4_1/lib/libavutil.56.dylib
/usr/local/Cellar/ffmpeg/4.1.4_1/lib/libavutil.dylib
Now, your problem is that the libavutil (and ffmpeg) on your system is not backwards-compatible with your Mac 10.10. It was built targeting a newer Mac 10.12, which seems to have introduced changes to the clock_gettime API, causing the "Symbol not found" error. This has also been reported to the opencv-python issues:
This is not related to OpenCV. The error comes from libavutil
(=FFmpeg) which is installed via homebrew. The error is related to
binary backward compatibility (apparently Apple has changed the
libsystem interface). I'm not too familiar with Apples ecosystem but
building FFmpeg against earlier OS version might fix the issue if the
older symbols are present also in the latest OS versions. Full
backward compatibility on macOS might be impossible to achieve.
I was just bitten by this issue the hard way deep in nested
dependencies; FFmpeg targets 10.12 but I'm on 10.11. Hoping for a
fixed release soon.
Note that while downgrading Xcode may work too, the proper way to
target an earlier version of macOS is to add e.g.
-mmacosx-version-min=10.11 or -mmacosx-version-min=10.6 to CFLAGS/CXXFLAGS/LDFLAGS; this will tune headers, compiler and linker
to produce a binary that is compatible with at least that version of
macOS.
The only solution it seems, is to install an older version of ffmpeg (with libavutil) that is compatible with your Mac 10.10, and then tell OpenCV to link to that older version. You'll probably need to also build OpenCV from source (see Configure and Build OpenCV to Custom FFMPEG Install).
You can also try checking this post over at SuperUser:
Which ffmpeg package I should download for macOS?
Try installing the older ffmpeg#2.8 from Homebrew (though I'm not sure if that's going to work, I don't have a Mac 10.10 to test it on).
Try downloading pre-built static/shared builds from ffmpeg.org.
Try building it from source (see CompilationGuide/macOS)

Speech Recognition. Module installed but won't work

Trying to get the speech recognition module to work. I have it working on my Windows 10 laptop, my Raspberry pi3 but I can't seem to get it to work on Ubuntu! The module has been install but neither PyCharm or Thonny can find it.
I've searched through stack overflow for a solution and haven't been successful. I've tried uninstalling and reinstalling the module. I've tried various versions of installing the module such as using the setuup.py file or pip, tried moving the folders/files where they should be etc..
(Also tried telling the Computer he's a good boy but that didn't work either...)
I can use this line of code
python3 -m speech_recognition
With my mic plugged into the tower and it works, but when using a line in PyCharm or Thonny such as
import speech_recognition
print(speech_recognition.__version__)
I end up with
Traceback (most recent call last):
File "/home/elitree/SPRECOG/FU.py", line 1, in <module>
import speech_recognition
ModuleNotFoundError: No module named 'speech_recognition'
python version is 3.6
pip3 version is 19.1.1
Ubuntu version is Ubuntu 18.04.2 LTS
I can provide other system details if needed
I'm just not sure what to do now
As ForceBru explained to me - My IDE was using the wrong python interpreter.
Which is first identified by running the Python script in the terminal with python3 this_file.py
After this the problem could be fixed by identifying the correct interpreter using the command which python3 in the terminal and then configuring the IDE to use that interpreter.

How do I correctly install PyQt5 module against Intel Python 3.6.x (64 bit)?

I am attempting to install the module PyQt5 against my Intel Python 3.6 installation running on a 64 bit Windows 10 OS. PyQt5 5.12 is installed correctly (as far as I can tell) via pip, however I am getting the below error when running my code. I understand that Intel Python 3.6 is a 64 bit application and that the error means that PyQt5 is 32 bit...however I'm not sure what to do about it.
I have the reference Python 3.7 installed and fully working with PyQt5. I have another version of PyQt5 installed elsewhere on my system. Is it possible that my dll files are linked to this other installation?
Traceback (most recent call last):
File
"C:/Users/my_username/PycharmProjects/iAnalysis/venv/gui/hypergeometric_calculator.py", line 16, in <module>
from PyQt5.QtCore import Qt
ImportError: DLL load failed: %1 is not a valid Win32 application.
It appears that as of June 2019 Intel Python is not compatible with PyQt5 and therefore there is no answer to this question at the moment.

Python 3.6 not finding modules that Python 3.5 can find

I am trying to make a discord bot based on this repository https://github.com/sleibrock/discord-bots
It uses Python 3.6, but when I try to use it I get the error
Traceback (most recent call last):
File "Bot.py", line 9, in <module>
from discord.py import Client, Game
ModuleNotFoundError: No module named 'discord'
In python3.5 >>>import discord runs fine.
In python3.6 >>>import discord gives the same error as above.
Any help would be appreciated.
edit: I copied all files from /usr/lib/python3.5/site-packages and /usr/lib64/python3.5/site-packages to the python3.6 counterparts which seems to have fixed the problem. It seems like it wasn't installing anything into the python3.6 folders and was checking the 3.5 folders, making something break with the import.
Python allows for different versions being installed independently of each other. Each one will have its own packages, which make sense because some packages require a minimal (or specific) version, and packages for Python2 could not work in Python3. In addition, packages using compiled C library will be different between 32bits and 64 bits versions.
It is a feature, because it allows you to install some packages only for one of the different versions you have on your system, but it also mean that you have to install them in all the versions you want to use with them.

How to install PyGObject on windows in a anaconda virtual env

I want to use Gtk with python under windows. I already have Anaconda installed on windows. In order not to mess up everything and to have some easiness uninstalling/reinstalling, I would like to have a virtual env created with conda, working with that Gtk installation. But I don't seems to be able to make it work.
Here is my process. I first create a raw Ananconda virtual env with
conda create -n gtk-exporter python
The virtual environment is located at C:\Anaconda3\envs\gtk-exporter.
I then download the latest windows installer for PyGObject at http://sourceforge.net/projects/pygobjectwin32/files/?source=navbar
I extract and execute the installer and tell it to use a portable python install at C:\Anaconda3\envs\gtk-exporter. I only select Base, GTK and Glade for installation. The installation finished in a second and says it's successful.
Then within windows' shell, I activate the new environment with activate gtk-exporter. However when I try to import gtk, it fails, not finding gi.repository.
>>> from gi.repository import Gtk
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'gi'
What's wrong here ? C:\Anaconda3\envs\gtk-exporter\Lib\site-package contains a folder gnome with a lot of stuff including *.dlls, *.exe's and unix-looking folders like etc, lib or share, but I don't see a init.py or something pythonic. Am I missing a step.
Thank you for your help !
The problem was that I used python 3.5, whereas it is not supported. The installer should not have allowed me to install with python 3.5. I filed a bug report to signal it.
I solved the problem by uninstalling python 3.5 and installing python 3.4.

Resources