【问题标题】:ubuntu 14.04 pyenv install failubuntu 14.04 pyenv 安装失败
【发布时间】:2019-03-28 07:48:16
【问题描述】:

使用命令“lsb_release -a”,

没有可用的 LSB 模块。

分销商 ID:Ubuntu

说明:Ubuntu 14.04.5 LTS

发布:14.04

代号:可信赖

我关注了这个页面, https://github.com/pyenv/pyenv#basic-github-checkout

但安装失败。

  1. 克隆https://github.com/pyenv/pyenv
  2. 添加命令 $ echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile $ echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile $ echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.bash_profile
  3. source ~/.bash_profile 返回:没有这样的文件或目录

另外,我的echo "$PATH"/home/vagrant/.pyenv/bin:/home/vagrant/.rbenv/plugins/ruby-build/bin:/home/vagrant/.rbenv/shims:/home/vagrant/.rbenv/bin:/home/vagrant/.pyenv/bin:/home/vagrant/.rbenv/plugins/ruby-build/bin:/home/vagrant/.rbenv/shims:/home/vagrant/.rbenv/bin:/home/vagrant/.pyenv/bin:/home/vagrant/.rbenv/plugins/ruby-build/bin:/home/vagrant/.rbenv/shims:/home/vagrant/.rbenv/bin:/home/vagrant/.rbenv/plugins/ruby-build/bin:/home/vagrant/.rbenv/shims:/home/vagrant/.rbenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin

我该如何解决这个问题?

下面还有我的~/.bash_profile...

[[ -f ~/.bashrc ]] && source ~/.bashrc

导出 PYENV_ROOT="$HOME/.pyenv"

导出 PATH="$PYENV_ROOT/bin:$PATH"

if 命令 -v pyenv 1>/dev/null 2>&1;那么

eval "$(pyenv init -)"

fi

MY TERMINAL PHOTO: bashrc exists and One&only

这是我的 ~/.bash_profile

vagrant@vagrant-ubuntu-trusty-64:~$ cat ~/.bash_profile

[[ -f ~/.bashrc ]] && source ~/.bashrc

#export PYENV_ROOT="$HOME/.pyenv"
#export PATH="$PYENV_ROOT/bin":$PATH
vagrant@vagrant-ubuntu-trusty-64:~$

这是我的 ~/.bashrc

vagrant@vagrant-ubuntu-trusty-64:~$ cat ~/.bashrc
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
export SSL_CERT_FILE=/usr/local/share/ca-certificates/HQSSL.crt
export REQUESTS_CA_BUNDLE=/usr/local/share/ca-certificates/HQSSL.crt
# If not running interactively, don't do anything
case $- in
    *i*) ;;
      *) return;;
esac

# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth

# append to the history file, don't overwrite it
shopt -s histappend

# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000

# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize

# If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
#shopt -s globstar

# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"

# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
    debian_chroot=$(cat /etc/debian_chroot)
fi

# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
    xterm-color) color_prompt=yes;;
esac

# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
#force_color_prompt=yes

if [ -n "$force_color_prompt" ]; then
    if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
        # We have color support; assume it's compliant with Ecma-48
        # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
        # a case would tend to support setf rather than setaf.)
        color_prompt=yes
    else
        color_prompt=
    fi
fi

if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt

# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
    ;;
*)
    ;;
esac

# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
    alias ls='ls --color=auto'
    #alias dir='dir --color=auto'
    #alias vdir='vdir --color=auto'

    alias grep='grep --color=auto'
    alias fgrep='fgrep --color=auto'
    alias egrep='egrep --color=auto'
fi

# some more ls aliases
alias ll='ls -l'
alias la='ls -A'
alias l='ls -CF'

# Add an "alert" alias for long running commands.  Use like so:
#   sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'

# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.

if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi

# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
  if [ -f /usr/share/bash-completion/bash_completion ]; then
    . /usr/share/bash-completion/bash_completion
  elif [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
  fi
fi

export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"
export KAFKA_HOST="10.20.30.33"
export KAFKA_PORT=19092

alias python=python3
alias pip=pip3

alias pbcopy='xclip -selection clipboard'
alias pbpaste='xclip -selection clipboard -o'


#export PATH="$HOME/.pyenv/bin:$PATH"
#export PATH="$PYENV_ROOT/bin:$PATH"
#if command -v pyenv 1>/dev/null 2>&1; then
#  eval "$(pyenv init -)"
#fi


#eval "$(pyenv init -)"
#eval "$(pyenv virtualenv-init -)"



export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH"

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

source ~/.nvm/nvm.sh
export HISTTIMEFORMAT="%d/%m/%y %T "

【问题讨论】:

  • 先没有~/.bash_profile然后有?
  • @UlrichEckhardt 我添加了我的终端照片。请理解我只附上图片作为链接,因为我只有3个声望
  • 谢谢,这是个好主意。但是,如果您复制文本会更好,因为它甚至可以搜索。另外,该文本是否回答了我的问题?
  • 是的,我尝试附加一个链接到该命令的执行。通过键入 vi~/.bash 并按 tab 键数次显示的文件列表。 .bash_history .bash_logout .bash_profile .bashrc 如您所见,.bash_profile 是唯一的一个。

标签: python bash pyenv


【解决方案1】:

这个命令还有问题吗?

source ~/.bash_profile

无论如何,警告,我认为您的文件中有语法问题,在 PATH 定义中使用引号,使其认为整个路径只是一个路径,您应该这样更改:

export PATH="$PYENV_ROOT/bin":$PATH

查看修改后引号的位置。

编辑后的其他信息:

  • 仍有错误的报价,请更新以下所有 export PATH="$HOME/.rbenv/bin:$PATH"export PATH="$HOME/.rbenv/bin":$PATH
  • 你应该在使用rbenv时添加安全防护,例如用command -v rbenv 1>/dev/null 2>&1 && eval "$(rbenv init -)"替换你的eval行
  • .bashrc 的末尾,您必须在源文件之前删除无用的 backslack(并使用 -f,而不是 -s),最后它应该给出:
    [ -f "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"  # This loads nvm
    [ -f "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

因此,您的最终source ~/.nvm/nvm.sh 是无用的,因为如果文件存在,您的if 指令已经完成了它。

无论如何,如果它仍然无法正常工作,您能否提供以下输出:

bash -x ~/.bashrc

【讨论】:

  • 我认为你是对的。当执行exec $"PATH" 而不是echo "$PATH" 时,No such file or directory 在路径之后打印。
  • 是的,无论如何您都不能执行“PATH”。您最初的问题解决了吗?
  • 你执行的猫:cat ~/.bash_profile && cat ~/.bashrc
  • @Bsqure 没有答案可以帮助我。仍然打印 : No such file or directory 我可以 cat ~/.bash_profile 和 ~/.bashrc
  • 是的,请向我们展示 ~/.bash_profile 和 ~/.bashrc 文件。
【解决方案2】:

这个错误是因为.bashrc 文件不存在。此外,您似乎正在将pyenv 环境变量添加到~/.bash_profile 并尝试获取.bashrc 文件。

尝试获取您已修改的文件

source ~/.bash_profile

或使用更改重新加载 shell

exec $SHELL 

【讨论】:

  • 嗯.. 事实上我现在有.bashrc 文件。我也尝试添加.bashrc文件和.bash_profile,但是如果source ~命令被执行,ubuntu没有返回这样的文件或目录。
  • 好的。执行上述命令时会发生什么?你能分享一下日志吗?
  • 如果我执行source ~/.bash_profile,它会返回: No such file or directory。如果我执行exec $SHELL,它也不会返回任何内容。但仍然失败pyenv versions
  • 您可以尝试使用绝对路径source /home/<user-name>/.bash_profile 吗?你是哪个用户?运行whoami
  • 执行whoami时,返回vagrant。而source /home/vagrant/.bash_profile 和以前一样source ~/.bash_profile ;-( ...
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-07-20
  • 2023-03-31
  • 2016-01-21
  • 2015-06-08
  • 1970-01-01
  • 1970-01-01
  • 2015-09-25
相关资源
最近更新 更多