pyenv / pyenv-installer

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

Pyenv installer does not add to path #112

Open sabotagebeats opened 3 years ago

sabotagebeats commented 3 years ago

Pyenv is not found after installer is ran. After adding code to .profile and .bashrc it is also not found. Finally after manually adding modified code from github, I get error code when I exit bash. This installer script does not function properly.

https://github.com/pyenv/pyenv/issues/1994

sabotagebeats commented 3 years ago

reinstalled clean ubuntu 20.04 LTS on wsl2, installed dependencies, ran script,

$ pyenv
Command 'pyenv' not found
sabotagebeats commented 3 years ago

according to uninstall instructions https://github.com/pyenv/pyenv-installer/blob/master/README.rst#uninstall the installer should automatically modify the .bashrc and it is not.

sabotagebeats commented 3 years ago

when installer script runs, it shows the following output.

WARNING: seems you still have not added 'pyenv' to the load path.

# (The below instructions are intended for common
# shell setups. See the README for more guidance
# if they don't apply and/or don't work for you.)

# Add pyenv executable to PATH and
# enable shims by adding the following
# to ~/.profile:

export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init --path)"

# If your ~/.profile sources ~/.bashrc,
# the lines need to be inserted before the part
# that does that. See the README for another option.

# If you have ~/.bash_profile, make sure that it
# also executes the above lines -- e.g. by
# copying them there or by sourcing ~/.profile

# Load pyenv into the shell by adding
# the following to ~/.bashrc:

eval "$(pyenv init -)"

# Make sure to restart your entire logon session
# for changes to profile files to take effect.

# Load pyenv-virtualenv automatically by adding
# the following to ~/.bashrc:

eval "$(pyenv virtualenv-init -)"
sabotagebeats commented 3 years ago

after following those instructions and restarting the terminal, I'm able to use pyenv but when I exit the terminal I get the error The terminal process "bash" terminated with exit code: 1. as mentioned here: https://github.com/pyenv/pyenv/issues/1994

connerxyz commented 3 years ago

Same issue.

sabotagebeats commented 3 years ago

@connerxyz were you able to fix it by adding the code to your .profile and .bashrc or did you still have the exit error code 1 issue? Are you using vscode with wsl2 ubuntu 20.04 LTS also?

cchanzl commented 3 years ago

have a look at the first solution in the link below

https://github.com/pyenv/pyenv-installer/issues/103

sabotagebeats commented 3 years ago

@cchanzl I tried the instructions there but still have the error code 1 https://github.com/pyenv/pyenv-installer/issues/103#issuecomment-800984446

The terminal process "bash" terminated with exit code: 1.

sabotagebeats commented 3 years ago

more context: https://github.com/ApeWorX/ape/issues/105

sabotagebeats commented 3 years ago

this should be a part of the pyenv installer script to ask the user if the user would like to add the required lines to the ~/.bashrc

iurisilvio commented 3 years ago

I hit the same issue today.

I think this happened with pyenv 2.0+ upgrade (first release in may 23). They changed the bashrc script to:

export PATH="$HOME/.pyenv/bin:$PATH" eval "$(pyenv init --path)" eval "$(pyenv virtualenv-init -)"

Second line was eval "$(pyenv init -)".

https://github.com/pyenv/pyenv/blob/master/README.md#basic-github-checkout

VikashKothary commented 3 years ago

This still looks broken for me?

The workaround I used since there was only one file was sudo ln -s "${HOME}/.pyenv/bin/pyenv" "/usr/local/bin/." which got it working.

EmanueleGallone commented 2 years ago

Same issue today. Installed with script on ubuntu 20.04, restarted shell and still

$pyenv
Command 'pyenv' not found

fixed by manually adding to ~/.bashrc the lines:

export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init --path)"
eval "$(pyenv virtualenv-init -)"

and then restarting the shell with exec $SHELL.

native-api commented 2 years ago

This still looks broken for me?

Did it ever work? From what I see in the code, Pyenv-Installer didn't ever edit shell startup files automatically.

iurisilvio commented 2 years ago

The script change worked for me.

native-api commented 2 years ago

fixed by manually adding to ~/.bashrc the lines:

Check Pyenv's and Pyenv-Virtualenv's README for the proper setup. With the code you gave, pyenv activate won't work.

E.g. for Ubuntu, that'll be (as of this writing):

sed -Ei -e '/^([^#]|$)/ {a \
export PYENV_ROOT="$HOME/.pyenv"
a \
export PATH="$PYENV_ROOT/bin:$PATH"
a \
' -e ':a' -e '$!{n;ba};}' ~/.profile
echo 'eval "$(pyenv init --path)"' >>~/.profile

echo 'eval "$(pyenv init -)"' >> ~/.bashrc

echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc

Then restart your login session.

thiagola92 commented 2 years ago

After installing the follow message appears

WARNING: seems you still have not added 'pyenv' to the load path.

# See the README for instructions on how to set up
# your shell environment for Pyenv.

# Load pyenv-virtualenv automatically by adding
# the following to ~/.bashrc:

eval "$(pyenv virtualenv-init -)"

Still fail to find pyenv after add "eval $(pyenv virtualenv-init -)" to .bashrc or .profile

I had to manually add to .bashrc

export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init --path)"
eval "$(pyenv virtualenv-init -)"
kyegupov commented 2 years ago

@anton-petrov it seems like the issue should be reopened: as it stands, the README for this project is incorrect, pyenv command won't work by itself after the installation

jheasly commented 2 years ago

Had the same issue w/ Mac OS X 10.15.7 using zsh. Had to manually add the shim path to .zshrc

Running % pyenv doctor would say all was good:

 % pyenv doctor
Cloning /Users/jheasly/.pyenv/plugins/pyenv-doctor/bin/.....
Installing python-pyenv-doctor...
python-build: use readline from homebrew
python-build: use zlib from xcode sdk
Installed python-pyenv-doctor to /var/folders/tq/1wdf1n1n75xfr3swdjtpq6jm0000gn/T/pyenv-doctor.20211103162934.85601/prefix

Congratulations! You are ready to build pythons!
 % 

... but the pyenv python wouldn't be found. The system python is what would launch when I did % python on the command line after setting a system python via pyenv. Once I manually added the shim to .zshrc, all worked.

p.s.: Also had to add

export LDFLAGS="-L/usr/local/opt/openssl@3/lib"
export CPPFLAGS="-I/usr/local/opt/openssl@3/include"

to .zshrc for % pyenv doctor to work.

sabotagebeats commented 2 years ago

https://github.com/pyenv/pyenv/issues/2148

sabotagebeats commented 2 years ago

After installing the follow message appears

WARNING: seems you still have not added 'pyenv' to the load path.

# See the README for instructions on how to set up
# your shell environment for Pyenv.

# Load pyenv-virtualenv automatically by adding
# the following to ~/.bashrc:

eval "$(pyenv virtualenv-init -)"

Still fail to find pyenv after add "eval $(pyenv virtualenv-init -)" to .bashrc or .profile

I had to manually add to .bashrc

export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init --path)"
eval "$(pyenv virtualenv-init -)"

I tried to manually add this and I get this error:

Failed to activate virtualenv.

Perhaps pyenv-virtualenv has not been loaded into your shell properly.
Please restart current shell and try again.
sabotagebeats commented 2 years ago

I was able to get it to activate with this

# pyenv
export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"

however it still is broken when trying to install it uses the wrong path

 Running setup.py develop for eth-ape
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/home/sabotage/ape/ape/setup.py'"'"'; __file__='"'"'/home/sabotage/ape/ape/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps --user --prefix=
         cwd: /home/sabotage/ape/ape/
    Complete output (18 lines):
    running develop
    WARNING: The user site-packages directory is disabled.
    error: can't create or remove files in install directory

    The following error occurred while trying to add or remove files in the
    installation directory:

        [Errno 2] No such file or directory: '/usr/lib/python3.8/site-packages/test-easy-install-14112.write-test'

    The installation directory you specified (via --install-dir, --prefix, or
    the distutils default setting) was:

        /usr/lib/python3.8/site-packages/

    This directory does not currently exist.  Please create it and try again, or
    choose a different installation directory (using the -d or --install-dir
    option).

    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/home/sabotage/ape/ape/setup.py'"'"'; __file__='"'"'/home/sabotage/ape/ape/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps --user --prefix= Check the logs for full command output.
sabotagebeats commented 2 years ago

https://github.com/ApeWorX/ape/issues/222

sabotagebeats commented 2 years ago

tried these commands and it didn't resolve the issue

rm -rf ~/.pyenv
sudo apt install zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev tk-dev libssl-dev llvm \
libncurses5-dev libncursesw5-dev xz-utils libffi-dev liblzma-dev python-openssl
curl -L https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | bash
pyenv update 
pyenv install 3.8.12
pyenv virtualenv 3.8.12 apeworx
sabotagebeats commented 2 years ago

changing my ~/.bashrc to this fixed the issue

# So pyenv gets recognized
export PATH="$PATH:$HOME/.pyenv/bin"
eval "$(pyenv init --path)"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
sabotagebeats commented 2 years ago

closing as I have gotten this to work. please reopen if anyone still faces issue.

davetapley commented 2 years ago

Can we get a re-open on this?

Per @sabotagebeats' comment you can get pyenv to work by manually appending to ~/.bashrc, but:

a. That is not mentioned in the docs (see below), and moreover: b. Surely is something this installer script can/should do automatically?


Example of following the docs:

$ docker run -it mcr.microsoft.com/vscode/devcontainers/base:0-focal bash                   
root ➜ / $ curl https://pyenv.run | bash

[...]

Unpacking objects: 100% (10/10), 2.92 KiB | 597.00 KiB/s, done.

WARNING: seems you still have not added 'pyenv' to the load path.

# See the README for instructions on how to set up
# your shell environment for Pyenv.

# Load pyenv-virtualenv automatically by adding
# the following to ~/.bashrc:

eval "$(pyenv virtualenv-init -)"

⬆️ this is already a red flag, but the docs only say to exec $SHELL:

root ➜ / $ exec $SHELL
root ➜ / $ pyenv
bash: pyenv: command not found

This leaves the user having to go back to the pyenv README (which doesn't make any mention of needed to manually append to ~/.bashrc in the Automatic installer section).

alexdelorenzo commented 2 years ago

Here's what happens when you follow the directions in the README on Ubuntu 21.10:

$ sudo apt install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev \
  libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev \
  liblzma-dev python3-openssl git && echo 'Success'
Success

$ curl https://pyenv.run | bash
[snip]
WARNING: seems you still have not added 'pyenv' to the load path.

# See the README for instructions on how to set up
# your shell environment for Pyenv.

# Load pyenv-virtualenv automatically by adding
# the following to ~/.bashrc:

eval "$(pyenv virtualenv-init -)"

$ echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc
$ exec $SHELL
$ pyenv
Command 'pyenv' not found, did you mean:
  command 'p7env' from deb libnss3-tools (2:3.61-1ubuntu2)

Similar problem when doing the same on Arch.

This was solved by copying and pasting the following into my ~/.bashrc from the "Uninstall" section of the README:

export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init --path)"
eval "$(pyenv virtualenv-init -)"

I agree with @davetapley's points.

211217613 commented 2 years ago

b. Surely is something this installer script can/should do automatically?

Came here to suggest that the install script should setup the entire environment so you can start using pyenv immediately.

211217613 commented 2 years ago

I'm taking a look at at nvms installer and it automatically modifies your shell environment via https://github.com/nvm-sh/nvm/blob/81fc05684de8b0b13aed401de64733e1d5d23a9a/install.sh#L345 and then adds the required lines to your shell config file here

the pyenv-installer should do something similar while also leaving an option of not modifying your shell config files if you already do that on your own.

For example I have separate files that my shell config loads if the binary is present.

tjyang commented 2 years ago

I added my note on how I get it to work on RL8 in https://github.com/pyenv/pyenv-installer/issues/103#issuecomment-1001179872 .

DestyNova commented 2 years ago

Is there a good reason why the installer doesn't automatically update the path in e.g. ~/.bashrc or ~/.zshrc? If so, perhaps it could at least echo some instructions to stdout that would give users a clue how to proceed. I wanted to add pyenv to some of our team workflows but for now I'll leave it out because other team members will get confused and angry with me when they get stuck. :sweat_smile:

raratiru commented 2 years ago

It worked by following the instructions in pyenv README for manual installation... but why use the installer then?

Or -at least- why the installer is not suggesting that one should read that section?

For Bash:

    If your ~/.profile sources ~/.bashrc (Debian, Ubuntu, Mint):

    # the sed invocation inserts the lines at the start of the file
    # after any initial comment lines
    sed -Ei -e '/^([^#]|$)/ {a \
    export PYENV_ROOT="$HOME/.pyenv"
    a \
    export PATH="$PYENV_ROOT/bin:$PATH"
    a \
    ' -e ':a' -e '$!{n;ba};}' ~/.profile
    echo 'eval "$(pyenv init --path)"' >>~/.profile

    echo 'eval "$(pyenv init -)"' >> ~/.bashrc
zaemiel commented 2 years ago

Here's what happens when you follow the directions in the README on Ubuntu 21.10:

$ sudo apt install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev \
  libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev \
  liblzma-dev python3-openssl git && echo 'Success'
Success

$ curl https://pyenv.run | bash
[snip]
WARNING: seems you still have not added 'pyenv' to the load path.

# See the README for instructions on how to set up
# your shell environment for Pyenv.

# Load pyenv-virtualenv automatically by adding
# the following to ~/.bashrc:

eval "$(pyenv virtualenv-init -)"

$ echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc
$ exec $SHELL
$ pyenv
Command 'pyenv' not found, did you mean:
  command 'p7env' from deb libnss3-tools (2:3.61-1ubuntu2)

Similar problem when doing the same on Arch.

This was solved by copying and pasting the following into my ~/.bashrc from the "Uninstall" section of the README:

export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init --path)"
eval "$(pyenv virtualenv-init -)"

I agree with @davetapley's points.

The same for me. Have to add these lines manually to .bashrc on Linux Mint 20.1

telometto commented 2 years ago

fixed by manually adding to ~/.bashrc the lines:

Check Pyenv's and Pyenv-Virtualenv's README for the proper setup. With the code you gave, pyenv activate won't work.

E.g. for Ubuntu, that'll be (as of this writing):

sed -Ei -e '/^([^#]|$)/ {a \
export PYENV_ROOT="$HOME/.pyenv"
a \
export PATH="$PYENV_ROOT/bin:$PATH"
a \
' -e ':a' -e '$!{n;ba};}' ~/.profile
echo 'eval "$(pyenv init --path)"' >>~/.profile

echo 'eval "$(pyenv init -)"' >> ~/.bashrc

echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc

Then restart your login session.

I'm using Fedora 35 with bash, so I used the "appropriate" command under 'Configure your shell's environment for Pyenv', but I am experiencing the same issues as everyone else in this thread. There seems to be something wrong with how and/or where it is being defined. I managed to get around it by just adding source ~/.profile to my .bashrc.

jds-amplify commented 2 years ago
WARNING: seems you still have not added 'pyenv' to the load path.

# See the README for instructions on how to set up

Which README? Where? The README for this repo?

shadycuz commented 2 years ago

Still broken in 2022 <3

arkanoid87 commented 2 years ago

yep, broken

Mirandatz commented 2 years ago

I am still having this issue.

zaemiel commented 2 years ago

I am still having this issue.

For Ubuntu-based Linux distros try to use my script: https://github.com/zaemiel/ubuntu-pyenv-installer

pgy866 commented 1 year ago

This was solved by copying and pasting the following into my~/.bashrcfrom the"Uninstall" section of the README:

export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init --path)"
eval "$(pyenv virtualenv-init -)"

deepin 20.8

marcospgp commented 1 year ago

2023 now and no fix, maybe good idea to update readme? https://github.com/pyenv/pyenv-installer/pull/145

calohmn commented 7 months ago

There is still the WARNING: seems you still have not added 'pyenv' to the load path. output of the installer script.

This is misleading as it implies I should have adapted the PATH before running the installer. But I obviously can't do that if I need to run pyenv init for determining the PATH value.

cisarpavel commented 5 months ago

Still have the issue

Distributor ID: Ubuntu Description: Ubuntu 22.04.4 LTS Release: 22.04 Codename: jammy

$ curl https://pyenv.run | bash
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   270  100   270    0     0    513      0 --:--:-- --:--:-- --:--:--   514
Cloning into '/home/dummy/.pyenv'...
remote: Enumerating objects: 1242, done.
remote: Counting objects: 100% (1242/1242), done.
remote: Compressing objects: 100% (689/689), done.
remote: Total 1242 (delta 727), reused 707 (delta 420), pack-reused 0
Receiving objects: 100% (1242/1242), 618.36 KiB | 3.89 MiB/s, done.
Resolving deltas: 100% (727/727), done.
Cloning into '/home/dummy/.pyenv/plugins/pyenv-doctor'...
remote: Enumerating objects: 11, done.
remote: Counting objects: 100% (11/11), done.
remote: Compressing objects: 100% (9/9), done.
remote: Total 11 (delta 1), reused 5 (delta 0), pack-reused 0
Receiving objects: 100% (11/11), 38.72 KiB | 1.61 MiB/s, done.
Resolving deltas: 100% (1/1), done.
Cloning into '/home/dummy/.pyenv/plugins/pyenv-update'...
remote: Enumerating objects: 10, done.
remote: Counting objects: 100% (10/10), done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 10 (delta 1), reused 5 (delta 0), pack-reused 0
Receiving objects: 100% (10/10), done.
Resolving deltas: 100% (1/1), done.
Cloning into '/home/dummy/.pyenv/plugins/pyenv-virtualenv'...
remote: Enumerating objects: 63, done.
remote: Counting objects: 100% (63/63), done.
remote: Compressing objects: 100% (56/56), done.
remote: Total 63 (delta 11), reused 29 (delta 0), pack-reused 0
Receiving objects: 100% (63/63), 41.13 KiB | 2.06 MiB/s, done.
Resolving deltas: 100% (11/11), done.

WARNING: seems you still have not added 'pyenv' to the load path.

bash: line 88: /home/dummy/.pyenv/bin/pyenv: Permission denied
bash: line 89: /home/dummy/.pyenv/bin/pyenv: Permission denied
cisarpavel commented 5 months ago

Still have the issue

Distributor ID: Ubuntu Description: Ubuntu 22.04.4 LTS Release: 22.04 Codename: jammy

$ curl https://pyenv.run | bash
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   270  100   270    0     0    513      0 --:--:-- --:--:-- --:--:--   514
Cloning into '/home/dummy/.pyenv'...
remote: Enumerating objects: 1242, done.
remote: Counting objects: 100% (1242/1242), done.
remote: Compressing objects: 100% (689/689), done.
remote: Total 1242 (delta 727), reused 707 (delta 420), pack-reused 0
Receiving objects: 100% (1242/1242), 618.36 KiB | 3.89 MiB/s, done.
Resolving deltas: 100% (727/727), done.
Cloning into '/home/dummy/.pyenv/plugins/pyenv-doctor'...
remote: Enumerating objects: 11, done.
remote: Counting objects: 100% (11/11), done.
remote: Compressing objects: 100% (9/9), done.
remote: Total 11 (delta 1), reused 5 (delta 0), pack-reused 0
Receiving objects: 100% (11/11), 38.72 KiB | 1.61 MiB/s, done.
Resolving deltas: 100% (1/1), done.
Cloning into '/home/dummy/.pyenv/plugins/pyenv-update'...
remote: Enumerating objects: 10, done.
remote: Counting objects: 100% (10/10), done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 10 (delta 1), reused 5 (delta 0), pack-reused 0
Receiving objects: 100% (10/10), done.
Resolving deltas: 100% (1/1), done.
Cloning into '/home/dummy/.pyenv/plugins/pyenv-virtualenv'...
remote: Enumerating objects: 63, done.
remote: Counting objects: 100% (63/63), done.
remote: Compressing objects: 100% (56/56), done.
remote: Total 63 (delta 11), reused 29 (delta 0), pack-reused 0
Receiving objects: 100% (63/63), 41.13 KiB | 2.06 MiB/s, done.
Resolving deltas: 100% (11/11), done.

WARNING: seems you still have not added 'pyenv' to the load path.

bash: line 88: /home/dummy/.pyenv/bin/pyenv: Permission denied
bash: line 89: /home/dummy/.pyenv/bin/pyenv: Permission denied

Check https://github.com/pyenv/pyenv/issues/332#issuecomment-81199008 Can be helpful for this issue.