How to solve AttributeError: module 'uhd' has no attribute 'usrp' - python

I know it is a wide answered question, however, I could solve it. When I'm trying to execute the command
usrp = uhd.usrp.MultiUSRP()
from https://pysdr.org/content/usrp.html I get this error
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'uhd' has no attribute 'usrp'
I've executed:
export PYTHONPATH="/usr/local/lib/python3.8/site-packages/"
Inside lib I have:
/use/local/lib/python3.8/site-packages$ ls
uhd usrp_mpm
Inside uhd there are the following files (including usrp):
/usr/local/lib/python3.8/site-packages/uhd$ ls
chdr.py imgbuilder property_tree.py usrp
dsp __init__.py rfnoc.py usrpctl
filters.py libpyuhd.cpython-38-x86_64-linux-gnu.so types.py utils
And inside usrp:
/usr/local/lib/python3.8/site-packages/uhd/usrp$ ls
cal __init__.py libtypes.py multi_usrp.py
The version of python is:
Python 3.8.10 (default, Jun 22 2022, 20:18:18)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
The SO is:
Distributor ID: Ubuntu
Description: Ubuntu 20.04.5 LTS
Release: 20.04
Codename: focal
Anything missing?

Related

Cannot use socket

I am trying to import socket and I get the following error:
$ python
Python 2.7.16 |Anaconda, Inc.| (default, Mar 14 2019, 16:24:02)
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import socket
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "socket.py", line 68, in <module>
from _ssl import \
ImportError: cannot import name RAND_egd
I thought that perhaps my Anaconda installation was corrupted so I uninstalled and reinstalled Anaconda but the error persists.
I had tried what the other posts suggested except for editing socket.py due to Macos System Integrity Protection. My guess is that the problem lies elsewhere as I doubt that everyone has had to edit the file.
How can I find the source of the problem?

import mlpack fails in python

I am trying to use mlpack in python scripts. I just installed the mlpack package from source into my directory /home/glassjawed/local/ and
glassjawed#Y9Acer:~$ ls local/lib | grep mlpack
libmlpack.so
libmlpack.so.3
libmlpack.so.3.0
glassjawed#Y9Acer:~$ ls local/include/mlpack/bindings/python
get_arma_type.hpp print_defn.hpp
get_cython_type.hpp print_doc_functions.hpp
get_numpy_type_char.hpp print_doc_functions_impl.hpp
get_numpy_type.hpp print_doc.hpp
get_param.hpp print_input_processing.hpp
get_printable_param.hpp print_output_processing.hpp
get_python_type.hpp print_pyx.hpp
import_decl.hpp py_option.hpp
mlpack strip_type.hpp
print_class_defn.hpp
So mlpack is clearly installed. HOWEVER, I can't seem to run this in python because I get a module not found error.
glassjawed#Y9Acer:~$ python
Python 3.6.7 | packaged by conda-forge | (default, Nov 21 2018, 03:09:43)
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>> import mlpack
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'mlpack'
Why is this happening and how can I fix this? I tried everything.
`

Why do I get a ModuleNotFoundError for winreg on a Linux system?

'winreg' module is not found python 3.6.7. I am not facing this problem in Python 3.4.
Is any third-party app in 'winreg' that I can use same code or how can I solve this.
jaki#jaki-notebook:~$ python3 -V
Python 3.6.7
jaki#jaki-notebook:~$ python3
Python 3.6.7 (default, Oct 22 2018, 11:32:17)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from winreg import *
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'winreg'
>>>
ModuleNotFoundError: No module named 'winreg'
It is not work on linux because this package expose functions of the Windows registry API to Python
Read this documentation on python offical website

Intel DAAL python error

Intel Data Analytics Acceleration Library (Intel DAAL) has been installed successfully on my ubuntu. However, when running examples located at compilers_and_libraries_2017/linux/daal/examples/python/source/distance, I got following error. Anybody have this problem before?
$ source activate intelpython
(intelpython) W2600CR:/compilers_and_libraries_2017/linux/daal/examples/python/source/distance$
$ python3.5
Python 3.5.2 |Intel Corporation| (default, Feb 5 2017, 09:07:18)
[GCC 4.8.2 20140120 (Red Hat 4.8.2-15)] on linux
Type "help", "copyright", "credits" or "license" for more information.
Intel(R) Distribution for Python is brought to you by Intel Corporation.
Please check out: https://software.intel.com/en-us/python-distribution
>>>
(intelpython)$ :/compilers_and_libraries_2017/linux/daal/examples/python/source/distance$ python3.5 cos*.py
Traceback (most recent call last):
File "cos_dist_dense_batch.py", line 48, in <module>
DataSourceIface.doDictionaryFromContext
File "/media/liqisuccess/76F07852F0781A97/Ubuntu/App/Anaconda3/envs/intelpython/lib/python3.5/site-packages/daal/data_management/__init__.py", line 4540, in __new__
return FileDataSource_CSVFeatureManagerFloat64(*args)
File "/media/liqisuccess/76F07852F0781A97/Ubuntu/App/Anaconda3/envs/intelpython/lib/python3.5/site-packages/daal/data_management/__init__.py", line 3534, in __init__
this = _data_management.new_FileDataSource_CSVFeatureManagerFloat64(*args)
SystemError: Error on file open
I ran into the same problem. After I dig into the sample source, I found that it's due to the csv file path.
Just cd to compilers_and_libraries_2017/linux/daal/examples/python and run the sample again.

matplotlib: no module named compat

I have installed python-2.7.5-5ubuntu3 and matplotlib-1.3.1-1ubuntu5 from the ubuntu 14.04 repository via apt-get. Trying to import the library in python 2.7 raises the following import error:
harold#ubuntu:~$ python
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/share/pyshared/matplotlib/__init__.py", line 157, in <module>
from matplotlib.compat import subprocess
ImportError: No module named compat
>>>
I checked the directory /usr/share/pyshared/matplotlib and, indeed, cannot find any package called compat.
Any idea what is broken on my system?
Thanks!
I have found same problem on Ubuntu 16 & 14.
Possible source of the problem is damaged instance of matplotlib. Damaged instance overlaps working instance of matplotlib.
Please try to remove broken instance of matplotlib to solve the issue.
Firstly I have looked matplotlib instances:
find / |grep matplotlib | grep __init__\.py$ |more
Secondly I have deleted this folder:
find /usr/share/pyshared/matplotlib -delete

Categories

Resources