Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pyenv installer does not add to path #112

Open
sabotagebeats opened this issue Jun 28, 2021 · 45 comments · Fixed by #115
Open

Pyenv installer does not add to path #112

sabotagebeats opened this issue Jun 28, 2021 · 45 comments · Fixed by #115

Comments

@sabotagebeats
Copy link

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.

pyenv/pyenv#1994

@sabotagebeats
Copy link
Author

sabotagebeats commented Jun 28, 2021

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

$ pyenv
Command 'pyenv' not found

@sabotagebeats
Copy link
Author

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
Copy link
Author

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
Copy link
Author

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: pyenv/pyenv#1994

@connerxyz
Copy link

Same issue.

@sabotagebeats
Copy link
Author

@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
Copy link

cchanzl commented Jul 8, 2021

have a look at the first solution in the link below

#103

@sabotagebeats
Copy link
Author

sabotagebeats commented Jul 12, 2021

@cchanzl I tried the instructions there but still have the error code 1 #103 (comment)

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

@sabotagebeats
Copy link
Author

more context:
ApeWorX/ape#105

@sabotagebeats
Copy link
Author

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
Copy link
Contributor

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
Copy link

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
Copy link

EmanueleGallone commented Sep 18, 2021

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
Copy link
Member

native-api commented Oct 18, 2021

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
Copy link
Contributor

The script change worked for me.

@native-api
Copy link
Member

native-api commented Oct 18, 2021

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
Copy link

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
Copy link

kyegupov commented Nov 2, 2021

@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

@anton-petrov anton-petrov reopened this Nov 2, 2021
@jheasly
Copy link

jheasly commented Nov 3, 2021

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
Copy link
Author

pyenv/pyenv#2148

@sabotagebeats
Copy link
Author

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
Copy link
Author

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
Copy link
Author

ApeWorX/ape#222

@sabotagebeats
Copy link
Author

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://github.com/raw/pyenv/pyenv-installer/master/bin/pyenv-installer | bash
pyenv update 
pyenv install 3.8.12
pyenv virtualenv 3.8.12 apeworx

@sabotagebeats
Copy link
Author

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 -)"

@davetapley
Copy link

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).

@native-api native-api reopened this Nov 19, 2021
@alexdelorenzo
Copy link

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.

@pyenv pyenv deleted a comment from tkimnguyen Dec 7, 2021
@pyenv pyenv deleted a comment from OkYongChoi Dec 7, 2021
@211217613
Copy link

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
Copy link

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
Copy link

tjyang commented Dec 26, 2021

I added my note on how I get it to work on RL8 in #103 (comment) .

@DestyNova
Copy link

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. 😅

@raratiru
Copy link

raratiru commented Feb 7, 2022

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
Copy link

zaemiel commented Feb 17, 2022

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
Copy link

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
Copy link

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
Copy link

shadycuz commented Apr 1, 2022

Still broken in 2022 <3

@arkanoid87
Copy link

yep, broken

@Mirandatz
Copy link

I am still having this issue.

@zaemiel
Copy link

zaemiel commented Jul 29, 2022

I am still having this issue.

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

@pgy866
Copy link

pgy866 commented Jan 3, 2023

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
Copy link
Contributor

2023 now and no fix, maybe good idea to update readme? #145

@calohmn
Copy link

calohmn commented Jan 29, 2024

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
Copy link

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
Copy link

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 pyenv/pyenv#332 (comment)
Can be helpful for this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet