pyenv / pyenv-installer

This tool is used to install `pyenv` and friends.
MIT License
3.96k stars 428 forks source link

bash: pyenv: command not found and how to solve it #103

Closed goncaloperes closed 3 years ago

goncaloperes commented 3 years ago

In CentOS 7, I ran

$ curl https://pyenv.run | bash

and then

$ exec $SHELL

However when trying to see if I had pyenv installed by updating it

pyenv update

I was getting the error

bash: pyenv: command not found


Solution (found here)

It turns out the pyenv path wasn't exported to .bashrc. It can be done by executing the following commands in terminal:

echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.bashrc

Then restart the shell

exec "$SHELL"

NikosAlexandris commented 3 years ago

Same error under Funtoo-Linux. Using the above fix, the error message goes away, when starting a new interactive shell (terminal). However, when running

❯ pyenv
bash: pyenv: command not found

still errors out.

ba2tro commented 3 years ago

For Ubuntu OS, you can face the same problem. So, after installing the dependencies and pyenv in terminal just type the following commands one by one : $ export PATH="/home/username/.pyenv/bin:$PATH" $ eval "$(pyenv init -)" $ eval "$(pyenv virtualenv-init -)" Afterwards you can check if it worked by just hitting enter after typing pyenv This should return the help documentation of pyenv, i.e., the basic commands and other help content Your welcome!

bdv1234 commented 3 years ago

I have done the steps provided by @goncaloperes . but still I am getting below error.

I am using Centos 7. Can anyone face this issue ?

[centos@localhost ~]$ exec "$SHELL" WARNING: pyenv init - no longer sets PATH. Run pyenv init to see the necessary changes to make to your configuration.

native-api commented 3 years ago

Pyenv installer gives you instructions about what you need to do next (install Pyenv into the shell, it can't do that automatically due to many different shell setups out there).

Note that in version 2.0.0, the required shell setup has changed, so please heed the instructions (so that you don't waste your and our time reporting bugs that are not there).

iamrathore commented 2 years ago

For Ubuntu OS, you can face the same problem. So, after installing the dependencies and pyenv in terminal just type the following commands one by one : $ export PATH="/home/username/.pyenv/bin:$PATH" $ eval "$(pyenv init -)" $ eval "$(pyenv virtualenv-init -)" Afterwards you can check if it worked by just hitting enter after typing pyenv This should return the help documentation of pyenv, i.e., the basic commands and other help content Your welcome!

The problem is not solved, still getting the same error.

tjyang commented 2 years ago

on RL8, a note to myself or other.

After I exited out of 2nd bash spawn of 1st bash. the installer script works.

[me@rocky8t01 ~]$ ps
    PID TTY          TIME CMD
 816324 pts/0    00:00:01 bash
1061241 pts/0    00:00:00 bash
1062501 pts/0    00:00:00 ps
[me@rocky8t01 ~]$ exit
[me@rocky8t01 salt]$ ps
    PID TTY          TIME CMD
 816324 pts/0    00:00:01 bash
1062591 pts/0    00:00:00 ps
[me@rocky8t01 salt]$ curl https://pyenv.run | bash
<snipped>
[me@rocky8t01 salt]$ exec "$SHELL"
nuggetofwisdom commented 2 years ago

For Ubuntu OS, you can face the same problem. So, after installing the dependencies and pyenv in terminal just type the following commands one by one : $ export PATH="/home/username/.pyenv/bin:$PATH" $ eval "$(pyenv init -)" $ eval "$(pyenv virtualenv-init -)" Afterwards you can check if it worked by just hitting enter after typing pyenv This should return the help documentation of pyenv, i.e., the basic commands and other help content Your welcome!

I hope both sides of your pillow are cold tonight :)

Al-Sharabi commented 1 year ago

If you have downloaded pyenv to your home directory, all you have to do is add export PATH="$HOME/.pyenv/bin:$PATH" eval "$(pyenv init -)" eval "$(pyenv virtualenv-init -)" to either .bashrc if you are using bash or .zshrc if you are using Oh My Zsh.

urosch commented 10 months ago

If you are on a mac for example and use zsh use this:

echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc
echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.zshrc