【问题标题】:in python after importing sys how can i import terminal在导入 sys 后的 python 中,我如何导入终端
【发布时间】:2023-02-25 12:47:56
【问题描述】:

Python

import sys
from terminal import *

它说错误:无法解析导入“终端” 我是新来的,所以我可能在这里做了一些愚蠢的事情

我只是按照教程在终端中制作生命游戏

https://www.youtube.com/watch?v=bNsrHRJQdKo

【问题讨论】:

  • 您可能还没有在 python 环境中安装终端包。所以在你执行你的文件之前pip install terminal
  • terminal 是第三方模块。你必须自己安装它。

标签: python importerror


【解决方案1】:

sys 模块是 cPython 的标准配置。

相比之下,需要安装 terminal 模块, 通过关注these instructions。 总结是:

$ pip install terminal

这是一个例子。

$  python -c 'import terminal'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'terminal'
$
$  pip install terminal
Collecting terminal
  Downloading terminal-0.4.0.tar.gz (11 kB)
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: terminal
  Building wheel for terminal (setup.py) ... done
  Created wheel for terminal: filename=terminal-0.4.0-py3-none-any.whl size=13146 sha256=b21c66c1df3d12257d260258496192e87e1ea9ffe6295543c045d9934ec60651
  Stored in directory: .../Library/Caches/pip/wheels/97/31/65/c0048996b231771b909f29274f054b1540fe0019960bed84d4
Successfully built terminal
Installing collected packages: terminal
Successfully installed terminal-0.4.0
$
$  python -c 'import terminal'
$

(请注意,现在 import 已完成且未报告错误。)

【讨论】:

  • 嗯,这对我不起作用,所以我会尝试其他方法
猜你喜欢
  • 2018-02-09
  • 2019-10-03
  • 2018-06-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-02-22
  • 2011-04-21
  • 1970-01-01
相关资源
最近更新 更多