_curses.error:setupterm:找不到终端,Raspberry Pi

时间:2018-01-26 23:26:37

标签: terminal raspberry-pi ncurses python-curses

每次我在Raspberry Pi上运行这个脚本时:

error[E0597]: `texture` does not live long enough
   --> src\graphics\resourcepack.rs:164:63
    |
164 |             let sheet: Sampler<'a, Texture2d> = Sampler::new(&texture)
    |                                                               ^^^^^^^ borrowed value does not live long enough
...
182 |         }
    |         - borrowed value only lives until here
    |
note: borrowed value must be valid for the lifetime 'a as defined on the impl at 138:5...
   --> src\graphics\resourcepack.rs:138:5
    |
138 | /     impl<'a> DefaultResourcePack<'a> {
139 | |         fn new<F: Facade>(facade: &'a F) -> DefaultResourcePack<'a> {
140 | |             // construct regions
141 | |             let sheet_dim: f32 = 16.0;
...   |
182 | |         }
183 | |     }
    | |_____^

我收到错误:

app.UseMvc(routes =>
{
    routes.MapRoute(
        name: "default",
        template: "{controller=Home}/{action=Index}/{id?}");
});

我该如何解决这个问题?

我看到了一个帖子,它说要做以下事情:

  

您必须设置环境变量import curses import RPi.GPIO as GPIO GPIO.setwarnings(False) GPIO.setmode(GPIO.BOARD) motor1a = 7 motor1b = 11 motor1e = 22 motor2a = 13 motor2b = 16 motor2e = 15 GPIO.setup(motor1a,GPIO.OUT) GPIO.setup(motor1b,GPIO.OUT) GPIO.setup(motor1e,GPIO.OUT) GPIO.setup(motor2a,GPIO.OUT) GPIO.setup(motor2b,GPIO.OUT) GPIO.setup(motor2e,GPIO.OUT) screen = curses.initscr() curses.noecho() curses.cbreak() curses.halfdelay(3) screen.keypad(True) try: while True: char = screen.getch() if char == ord('q'): break elif char == curses.KEY_UP: GPIO.output(motor1a,GPIO.HIGH) GPIO.output(motor1b,GPIO.LOW) GPIO.output(motor1e,GPIO.HIGH) GPIO.output(motor2a,GPIO.HIGH) GPIO.output(motor2b,GPIO.LOW) GPIO.output(motor2e,GPIO.HIGH) # except SOMEEXCEPTION is missing here, I am not sure why there is an exception in the first place _curses.error: setupterm: could not find terminal ,如下所示:

     

TERM

但我不确定该在哪一步。

1 个答案:

答案 0 :(得分:1)

为了使用curses,您需要告诉您正在使用哪个终端,以便库可以发送正确的命令。这是通过运行shell中提供的命令来完成的,该命令位于运行程序的同一位置

$ export TERM=linux
$ export TERMINFO=/etc/terminfo
$ python3 myprogram.py

$是shell的提示,你可能还有别的东西)

正如我在评论中提到的,您的代码无论如何都不会运行,except之后缺少try(我不确定您需要try为什么,以及无论如何你都需要理解这一点,以便捕获正确的例外)