首页 > 解决方案 > 本地发送的相同命令有效,但远程发送时无效?

问题描述

我想知道是否有人可以提供帮助,我使用以下图形命令针对同一主机..

当我直接登录到主机时,它执行得很好。(忽略标准的 graph_cli 错误)

pi@raspberrypi:~ $ graph shared/feed.csv -y 9,10 --ylabel Temp --title CabinTemp --figsize 1600x1000 --output shared/zzzz07.png

/usr/local/lib/python2.7/dist-packages/pandas/plotting/_converter.py:129: FutureWarning: Using an implicitly registered datetime converter for a matplotlib plotting method. The converter was registered by pandas on import. Future versions of pandas will require you to explicitly register matplotlib converters.

To register the converters:
        >>> from pandas.plotting import register_matplotlib_converters
        >>> register_matplotlib_converters()
  warnings.warn(msg, FutureWarning)

但是当我尝试使用这个 ssh 命令通过另一台机器将它发送到同一台主机时,(它适用于其他命令)

root@MiOS_54321:/# ssh -i /etc/dropbear/dropbear_rsa_host_key pi@192.168.1.37 graph shared/feed.csv -y 9,10 --ylabel Temp --title CabinTemp --figsize 1600x1000 --output shared/zzzz07.png

我收到此错误消息

Traceback (most recent call last):
  File "/usr/local/bin/graph", line 11, in <module>
    sys.exit(main.main())
  File "/usr/local/lib/python2.7/dist-packages/graph_cli/main.py", line 10, in main
    graphs = get_graph_defs(args)
  File "/usr/local/lib/python2.7/dist-packages/graph_cli/graph.py", line 171, in get_graph_defs
    graphs, globals = read_chain(args)
  File "/usr/local/lib/python2.7/dist-packages/graph_cli/graph.py", line 194, in read_chain
    data = stdin.buffer.read()
AttributeError: 'file' object has no attribute 'buffer'

有谁知道问题/修复可能是什么?

标签: pythonlinuxsshgraph

解决方案


看起来远程主机正在运行 Python 2,而您的本地主机正在运行 Python 3。在 Python 3 中,该sys.stdin对象具有一个buffer属性:

$ python3
[...]
>>> import sys
>>> sys.stdin.buffer
<_io.BufferedReader name='<stdin>'>

但是这个属性在 Python 2 中不存在:

$ python2
[...]
>>> import sys
>>> sys.stdin.buffer
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'file' object has no attribute 'buffer'

python3看起来您正在运行的代码需要 Python 3。如果您使用 eg或等显式运行它,远程主机可能确实有 Python3 可用pip3,但这是您必须检查的内容。


推荐阅读