【问题标题】:Gnuradio possible path issue prevents use python programsGnuradio 可能的路径问题阻止使用 python 程序
【发布时间】:2020-01-25 06:22:20
【问题描述】:

我在使用带有 python 程序的 gnuradio 时遇到了一些问题。我正在尝试将 gnuradio 与 gr-satellites 的 python 程序一起使用来解码来自 CubeSats 的数据包。当我尝试运行命令python filename.py 时,我收到以下输出

Traceback (most recent call last):
  File "taurus1_telemetry_parser.py", line 23, in <module>
    from gnuradio import gr
  File "/usr/local/lib/python3/dist-packages/gnuradio/gr/__init__.py", line 39, in <module>
    from .runtime_swig import *
  File "/usr/local/lib/python3/dist-packages/gnuradio/gr/runtime_swig.py", line 117
    def value(self) -> "PyObject *":
                    ^
SyntaxError: invalid syntax

(以下评论由原帖编辑)

事实证明,当 gnuradio 运行 python3 时,我的系统设置为运行 python 2.7.15。根据here. 发布的说明,我调整了我的系统以使其脱离 python 3.6.8 这将我的系统更改为正确运行 python3.6.8,但我认为我安装 gnuradio 不正确,因为我仍然遇到错误。

现在,如果我运行命令python3 filename.py,我会得到以下输出:

Traceback (most recent call last):
  File "taurus1_telemetry_parser.py", line 26, in <module>
    from . import by701_telemetry
ImportError: cannot import name 'by701_telemetry'

我使用命令pybombs remove gnuradio uhd 成功卸载了 gnuradio 的 pybombs 版本,如下面的 cmets 中所建议的,只安装了 ppa 版本。

由于 gnuradio 配置存在很多问题,我尝试查看是否可以轻松卸载 ppa 版本并重新开始使用 gnuradio。我进入了我的 gnuradio 目录(桌面/gnuradio/build)并尝试了make uninstall。执行make uninstall 进程没有产生任何错误,但这似乎并没有完全从我的系统中删除 gnuradio。

gnuradio 仍然可以在/usr/local/lib/python3/dist-packages 中找到,当我尝试运行 python 脚本时仍然会收到 ImportError。但是,现在当我输入head /usr/local/bin/gnuradio-companion 时,我收到以下消息:

head: cannot open '/usr/local/bin/gnuradio-companion' for reading: No such file or directory

which gnuradio-companion 的输出是:

 /usr/bin/gnuradio-companion

我有点不知道现在在这里做什么。关于如何修复或完全卸载 gnuradio 的任何想法?

【问题讨论】:

    标签: python-3.x linux path syntax-error gnuradio


    【解决方案1】:

    问题很可能是您使用 python2 启动程序,而 gnuradio 已使用 python3 编译。

    您需要在程序的第一行明确指定需要使用 python3 解释器(此行称为shebang

    #!/usr/bin/python3
    

    或按以下方式启动您的程序

    $ python3 ./my_program.py
    

    我通过 ppa 和 pybombs 安装了 gnuradio。

    有两个版本可能会导致很多问题。我的建议是使用 PPA 版本并删除使用 pybombs 安装的版本

    $ pybombs remove gnuradio uhd
    

    【讨论】:

    • 嗨,Vasil - 我实现了你的建议,但我现在遇到了一些新错误。我调整了我原来的帖子来详细说明这些。您对新问题有什么想法吗?
    • “可能会导致很多问题”:肯定会导致很多问题。我不建议 99.5% 的用户使用 PyBOMBS。很好的答案!
    • @sroger13 可能是手动安装与 PPA 安装混合的一些残余。
    • @MarcusMüller 你对我如何摆脱手动安装有什么想法吗?是否有我可能想要手动删除或类似的特定文件夹?
    • @sroger13 执行find /usr/local/ -name "*gnuradio*" -or -name "*uhd*" -or -name "*volk*" -or -name "*pmt*",检查输出是否只包含gnuradio相关文件,并返回带有-delete选项的相同命令,以删除所有列出的文件。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-09-03
    • 1970-01-01
    • 2011-05-10
    • 2013-07-09
    • 1970-01-01
    • 2019-06-13
    • 1970-01-01
    相关资源
    最近更新 更多