如何在Python Virtualenv中安装GNU收音机

发布于 2025-01-23 17:22:48 字数 2059 浏览 4 评论 0原文

我试图让Gnuradio在Virtualenv中工作。我想保持系统有些干净,我的项目需要Python 3.9,但是我的系统Python为3.8(Ubuntu 20.04.4 LTS)。

我使用sudo apt install gnuradio安装它,但是随后它最终进入了系统 dist-tackages ,我无法将其导入到Virtualenv中。运行系统python时,导入效果正常。

我试图重新创建我的Virtualenv以使用系统软件包:

python3.9 -m Venv -system-Site-site-spakages venv

这至少使我的Virtualenv能够找到Gnuradio,但是当我尝试导入其他东西时它以几种不同的方式失败。

>>> from gnuradio import uhd
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/gnuradio/uhd/__init__.py", line 21, in _prepare_uhd_python
    from . import uhd_python
ImportError: cannot import name 'uhd_python' from partially initialized module 'gnuradio.uhd' (most likely due to a circular import) (/usr/lib/python3/dist-packages/gnuradio/uhd/__init__.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/gnuradio/uhd/__init__.py", line 68, in <module>
    _prepare_uhd_python()
  File "/usr/lib/python3/dist-packages/gnuradio/uhd/__init__.py", line 26, in _prepare_uhd_python
    from . import uhd_python
ImportError: cannot import name 'uhd_python' from partially initialized module 'gnuradio.uhd' (most likely due to a circular import) (/usr/lib/python3/dist-packages/gnuradio/uhd/__init__.py)
>>> import pmt
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pmt/__init__.py", line 34, in <module>
    from .pmt_python import *
ModuleNotFoundError: No module named 'pmt.pmt_python'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/pmt/__init__.py", line 38, in <module>
    from .pmt_python import *
ModuleNotFoundError: No module named 'pmt.pmt_python'

我已经为此挣扎了几天,但没有找到解决方案。 甚至有可能从虚拟的内部运行GNU无线电?

I am trying to get gnuradio to work in a virtualenv. I want to keep my system somewhat clean and my project needs Python 3.9, but my system Python is 3.8 (Ubuntu 20.04.4 LTS).

I install it using sudo apt install gnuradio, but then it ends up in the system dist-packages and I can't import it in my virtualenv. The imports work fine when running the system Python.

I have tried to recreate my virtualenv to use system packages:

python3.9 -m venv --system-site-packages venv

This at least made my virtualenv able to find gnuradio, but when I try importing stuff it fails in several different ways.

>>> from gnuradio import uhd
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/gnuradio/uhd/__init__.py", line 21, in _prepare_uhd_python
    from . import uhd_python
ImportError: cannot import name 'uhd_python' from partially initialized module 'gnuradio.uhd' (most likely due to a circular import) (/usr/lib/python3/dist-packages/gnuradio/uhd/__init__.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/gnuradio/uhd/__init__.py", line 68, in <module>
    _prepare_uhd_python()
  File "/usr/lib/python3/dist-packages/gnuradio/uhd/__init__.py", line 26, in _prepare_uhd_python
    from . import uhd_python
ImportError: cannot import name 'uhd_python' from partially initialized module 'gnuradio.uhd' (most likely due to a circular import) (/usr/lib/python3/dist-packages/gnuradio/uhd/__init__.py)
>>> import pmt
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pmt/__init__.py", line 34, in <module>
    from .pmt_python import *
ModuleNotFoundError: No module named 'pmt.pmt_python'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/pmt/__init__.py", line 38, in <module>
    from .pmt_python import *
ModuleNotFoundError: No module named 'pmt.pmt_python'

I have struggled with this for several days now and found no solution. Is it even possible to run GNU Radio from within a virtualenv?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你的笑 2025-01-30 17:22:48

我已经为此挣扎了几天,没有找到解决方案。

您的发行版的GNU广播套件是针对发行版的Python构建的,因此您不能与其他Python一起使用。

因此,这是预期的。

甚至可以从Virtualenv内部运行GNU收音机?

当然,您还需要从该Virtualenv构建它,并告诉cmake -dcmake_install_prefix =/path/to/virtualenv/code>以安装在其中。

我们有一个非常不错的anaconda packager,所以使用conda 将GNU无线电安装到Python Prefix中可能是最简单的选择。

或者:

ubuntu 20.04.4 lts

有一个新的Ubuntu LTS版本!如果您要进行系统升级到Ubuntu 22.04 LTS,则获得Python 3.10和当前的GNU Radio 3.10.1“免费”。

I have struggled with this for several days now and found no solution.

Your distro's GNU Radio package is built against your distro's python, so you can't use it with a different python.

So, this is expected.

Is it even possible to run GNU Radio from within a virtualenv?

Sure, you'd need to build it from that virtualenv as well, and tell cmake -DCMAKE_INSTALL_PREFIX=/path/to/virtualenv/ to install into it.

We have a pretty nice anaconda packager, so installing GNU Radio into a Python prefix using conda might be the easiest alternative to that.

Alternatively:

Ubuntu 20.04.4 LTS

There's a new Ubuntu LTS version out! If you go for a system upgrade to Ubuntu 22.04 LTS, you get Python 3.10, and a current GNU Radio 3.10.1 "for free".

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文