python - 本地发送的相同命令有效,但远程发送时无效?
问题描述
我想知道是否有人可以提供帮助,我使用以下图形命令针对同一主机..
当我直接登录到主机时,它执行得很好。(忽略标准的 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'
有谁知道问题/修复可能是什么?
解决方案
看起来远程主机正在运行 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
,但这是您必须检查的内容。
推荐阅读
- javascript - 在 JavaScript 中使用正则表达式,我如何对匹配项进行分组?
- c - 在一个 if 条件下比较三个整数变量 (C)
- wordpress - 有没有办法将 Facebook 帖子数据转换为 WordPress 上的产品?
- reactjs - Jest 如何在从表单向服务器提交数据时测试错误?
- java - 如何让数组的最后一列加起来?
- java - Android Studio getWritableDatabase(); 导致我的应用程序崩溃
- algorithm - 零填充缓冲区/文件的 CRC32 计算
- asp.net - 引导选项卡没有切换
- python - 在 pygame 'pygame.surface' 对象中出现错误不能下标
- android - 如果片段包含 AppBarLayout,BottomNavigationView 不会对片段内部的滚动做出反应