【问题标题】:Bash PATH is not a valid identifierBash PATH 不是有效的标识符
【发布时间】:2017-08-14 19:10:00
【问题描述】:

我在 Mac 上,当我打开我的 shell 时,它显示以下内容:

-bash: export: `/Users/jasoncollis/torch/install/bin/torch-activate:/usr/local/bin:/Users/jasoncollis/Library/Enthought/Canopy_64bit/User/bin:/Users/jasoncollis/anaconda/bin:/Library/Frameworks/Python.framework/Versions/3.5/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin': not a valid identifier

这是我的#.bash_profile# 文件:

# Setting PATH for Python 3.5
# The original version is saved in .bash_profile.pysave
PATH=":/Library/Frameworks/Python.framework/Versions/3.5/bin:${PATH}"
export PATH

# added by Anaconda3 4.2.0 installer
export PATH=":/Users/jasoncollis/anaconda/bin:$PATH"


# Added by Canopy installer on 2016-11-10
# VIRTUAL_ENV_DISABLE_PROMPT can be set to '' to make the bash prompt show that Canopy is active, otherwise 1
alias activate_canopy="source '/Users/jasoncollis/Library/Enthought/Canopy_64bit/User/bin/activate'"
VIRTUAL_ENV_DISABLE_PROMPT=1 source '/Users/jasoncollis/Library/Enthought/Canopy_64bit/User/bin/activate'
export PATH=":/usr/local/bin:$PATH"

export LC_CTYPE=en_US.UTF-8

export PATH=":/Users/jasoncollis/torch/install/bin/torch-activate:$PATH"

export PATH=":/Users/jasoncollis/torch/install/bin:$PATH"

我一直在尝试寻找解决方案,但到目前为止我所尝试的都没有奏效。非常感谢您的帮助!

【问题讨论】:

  • 乍一看,引号似乎不正确, 类型的倒引号应分别替换为 "'
  • 最后两个exports 绝对应该被"(而不是')包围,以便插入$PATH 变量
  • 我已经用双引号替换了单引号,用非倒引号替换了类型倒引号,它仍然有同样的问题:( - 我将用我更新的#.bash_profile 编辑原件#
  • 通常这意味着您的脚本中某处有 export $PATH 而不是 export PATH (注意前面没有 $ 符号)。但是我在你的帖子中没有看到。获取来源的文件呢? (VIRTUAL_ENV_DISABLE_PROMPT=1 source '/Users/jasoncollis/Library/Enthought/Canopy_64bit/User/bin/activate')
  • 哦,请确保您编辑了正确的文件。 Bash 读取 .bash_profile。不知道您为什么将文件称为#.bash_profile#。 (也许是某些编辑器或其他脚本创建的一些备份?)

标签: bash shell path


【解决方案1】:

确保您编辑了正确的文件。对于登录 shell,Bash 执行 .bash_profile 而不是 #.bash_profile#。后者看起来像是由文本编辑器或脚本创建的备份文件。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-11-28
    • 2015-01-22
    • 2020-11-06
    • 1970-01-01
    • 2013-08-05
    • 2012-06-21
    相关资源
    最近更新 更多