【问题标题】:Sublime text : tput: No value for $TERM and no -T specified崇高的文本:tput:$TERM 没有值,也没有指定 -T
【发布时间】:2020-07-26 08:01:23
【问题描述】:

[完全错误]

tput: No value for $TERM and no -T specified
tput: No value for $TERM and no -T specified
tput: No value for $TERM and no -T specified
/usr/bin/python: can't find '__main__' module in ''
[Finished in 0.1s with exit code 1]
[shell_cmd: python -u ""]
[dir: /Applications/Sublime Text.app/Contents/MacOS]
[path: /Library/Frameworks/Python.framework/Versions/3.8/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Frameworks/Mono.framework/Versions/Current/Commands]

我所做的只是打印('hello world!')

但不久前,我尝试安装/更新新版本的 python。 我正在尝试学习编码,不久前我做了一门课程,现在我注册了另一门课程,并希望拥有最新版本的 python。当我安装 python 3.8.2 时,我开始遇到问题。 甚至下载了我的第一个 IDE - pycharm 并且也有一些问题。但试图一次解决一个问题。 顺便说一下,使用 Mac OS!

【问题讨论】:

  • 如果没有看到您正在使用的 sublime-build 文件,很难说为什么会产生 tput 错误,因此包括在内可能会有所帮助。除此之外,您的 Python 错误是因为您在第一次尝试运行文件之前没有保存文件。
  • 我在哪里可以找到你建议的 sublime-build ?如果这是一个愚蠢的问题,我很抱歉。我真的很新
  • 在我的 ~/.bash_profile 我有 cd ~/Desktop PS1="$(tput setaf 2)[\w] \n $(tput setaf 196)$(tput sgr0)~: " # Setting PATH for Python 3.6 # 原始版本保存在 .bash_profile.pysave PATH="/Library/Frameworks/Python.framework/Versions/3.6/bin:${PATH}" export PATH alias python=python3 # Setting PATH for Python 3.8 # 原始版本保存在.bash_profile.pysave PATH="/Library/Frameworks/Python.framework/Versions/3.8/bin:${PATH}" export PATH

标签: python python-3.x macos terminal sublimetext3


【解决方案1】:

我看到了错误 PS1="$(tput setaf 2)[\w] \n $(tput setaf 196)$(tput sgr0)~:" 为了更好地保存您的 PS 个人资料,我建议您使用 PS1="\033[32m][\w] \n \033[0m]~:"

tput 通常在为基于 linux 的操作系统编码时使用,因为在 Mac 操作系统上它会接受命令但也会干扰其他事情。 最好按照我的建议使用 for bash 的原始命令。

【讨论】:

  • 您应该更好地格式化答案中的代码。
【解决方案2】:

另一个解决方案是,您对 PS1 所做的更改(使用 tput)仅适用于 MacOS 中的交互式 shell。

使用 if 检查更新您的 .bash_profile.bashsrc

if [[ $- == *i* ]]
then
     PS1="$(tput setaf 2)[\w] \n $(tput setaf 196)$(tput sgr0)~:
fi

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-07-27
    • 1970-01-01
    • 1970-01-01
    • 2021-07-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多