iterm2 API: 连接调用失败 ('127.0.0.1', 1912)
iterm2 API: Connect call failed ('127.0.0.1', 1912)
我正在尝试 运行 此处定义的脚本:
https://iterm2.com/python-api/tutorial/example.html
import iterm2
async def main(connection):
app = await iterm2.async_get_app(connection)
window = app.current_window
if window is not None:
await window.async_create_tab()
else:
print("No current window")
iterm2.run_until_complete(main)
运行 脚本 (python3 code.py) 导致以下错误
File "code.py", line 20, in <module>
iterm2.run_forever(main)
File "/Users/naveen/ENV/mysite-env/lib/python3.8/site-packages/iterm2/connection.py", line 528, in run_forever
Connection().run_forever(coro, retry, debug)
File "/Users/naveen/ENV/mysite-env/lib/python3.8/site-packages/iterm2/connection.py", line 159, in run_forever
self.run(True, coro, retry, debug)
File "/Users/naveen/ENV/mysite-env/lib/python3.8/site-packages/iterm2/connection.py", line 240, in run
return loop.run_until_complete(self.async_connect(async_main, retry))
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
return future.result()
File "/Users/naveen/ENV/mysite-env/lib/python3.8/site-packages/iterm2/connection.py", line 416, in async_connect
async with self._get_connect_coro() as websocket:
File "/Users/naveen/ENV/mysite-env/lib/python3.8/site-packages/websockets/legacy/client.py", line 604, in __aenter__
return await self
File "/Users/naveen/ENV/mysite-env/lib/python3.8/site-packages/websockets/legacy/client.py", line 622, in __await_impl__
transport, protocol = await self._create_connection()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/base_events.py", line 1033, in create_connection
raise OSError('Multiple exceptions: {}'.format(
OSError: Multiple exceptions: [Errno 61] Connect call failed ('127.0.0.1', 1912), [Errno 61] Connect call failed ('::1', 1912, 0, 0)
python版本:3.8.3
iterm2 构建版本:3.3.10
iterm2 python 图书馆:iterm2==1.25
您需要在 iterm2 中安装 Python 运行time 并在单独的步骤中允许 Python 脚本,并安装 iterm2 模块。
安装 Python 运行时间:脚本 -> 管理 -> 运行时
允许 Python 脚本:首选项,常规选项卡,子选项卡 Magic:勾选“启用 Python API”复选框。 Mac OS'辅助功能设置会询问“启用PythonAPI?”,点击确定。
然后 运行 pip3 install iterm2
.
我正在尝试 运行 此处定义的脚本: https://iterm2.com/python-api/tutorial/example.html
import iterm2
async def main(connection):
app = await iterm2.async_get_app(connection)
window = app.current_window
if window is not None:
await window.async_create_tab()
else:
print("No current window")
iterm2.run_until_complete(main)
运行 脚本 (python3 code.py) 导致以下错误
File "code.py", line 20, in <module>
iterm2.run_forever(main)
File "/Users/naveen/ENV/mysite-env/lib/python3.8/site-packages/iterm2/connection.py", line 528, in run_forever
Connection().run_forever(coro, retry, debug)
File "/Users/naveen/ENV/mysite-env/lib/python3.8/site-packages/iterm2/connection.py", line 159, in run_forever
self.run(True, coro, retry, debug)
File "/Users/naveen/ENV/mysite-env/lib/python3.8/site-packages/iterm2/connection.py", line 240, in run
return loop.run_until_complete(self.async_connect(async_main, retry))
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
return future.result()
File "/Users/naveen/ENV/mysite-env/lib/python3.8/site-packages/iterm2/connection.py", line 416, in async_connect
async with self._get_connect_coro() as websocket:
File "/Users/naveen/ENV/mysite-env/lib/python3.8/site-packages/websockets/legacy/client.py", line 604, in __aenter__
return await self
File "/Users/naveen/ENV/mysite-env/lib/python3.8/site-packages/websockets/legacy/client.py", line 622, in __await_impl__
transport, protocol = await self._create_connection()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/base_events.py", line 1033, in create_connection
raise OSError('Multiple exceptions: {}'.format(
OSError: Multiple exceptions: [Errno 61] Connect call failed ('127.0.0.1', 1912), [Errno 61] Connect call failed ('::1', 1912, 0, 0)
python版本:3.8.3
iterm2 构建版本:3.3.10
iterm2 python 图书馆:iterm2==1.25
您需要在 iterm2 中安装 Python 运行time 并在单独的步骤中允许 Python 脚本,并安装 iterm2 模块。
安装 Python 运行时间:脚本 -> 管理 -> 运行时
允许 Python 脚本:首选项,常规选项卡,子选项卡 Magic:勾选“启用 Python API”复选框。 Mac OS'辅助功能设置会询问“启用PythonAPI?”,点击确定。
然后 运行 pip3 install iterm2
.