9

Pardon if already duplicate but I tried combing through the forums but it seems I can't get anywhere.

I am trying to install pyenv in Ubuntu 14.04 by doing these steps.

INSTALL PYENV DEPENDENCIES

sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm git

DOWNLOAD AND INSTALL PYENV

curl -L https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer | bash

YOU WILL SEE THIS MESSAGE

WARNING: seems you still have not added 'pyenv' to the load path. Load pyenv automatically by adding the following to ~/.bash_profile:

export PATH="$HOME/user/.pyenv/bin:$PATH"

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

CLOSE TERMINAL WINDOW AND OPEN ANOTHER ONE

No command 'pyenv' found, did you mean:
 Command 'p7env' from package 'libnss3-tools' (main)
pyenv: command not found
No command 'pyenv' found, did you mean:
 Command 'p7env' from package 'libnss3-tools' (main)
pyenv: command not found
user@ubuntu:~$ 

Please help how I can identify what seems to be the problem since I tried putting the script in .bashrc and .profile and still when I issue pyenv after opening another terminal the command is still not found.

WHERE I INSTALLED PYENV.

user@ubuntu:~$ ls -la | grep pyenv
ls: cannot access .gvfs: Permission denied
drwxrwxr-x 10 user user 4096 Jan 28 06:40 .pyenv
user@ubuntu:~$ cd .pyenv
user@ubuntu:~/.pyenv$ ls -la 
total 96
drwxrwxr-x 10 user user  4096 Jan 28 06:40 .
drwxr-xr-x 18 user user  4096 Jan 28 07:32 ..
drwxrwxr-x  2 user user  4096 Jan 28 06:40 bin
-rw-rw-r--  1 user user 12550 Jan 28 06:40 CHANGELOG.md
-rw-rw-r--  1 user user  7477 Jan 28 06:40 COMMANDS.md
drwxrwxr-x  2 user user  4096 Jan 28 06:40 completions
drwxrwxr-x  8 user user  4096 Jan 28 06:40 .git
-rw-rw-r--  1 user user    88 Jan 28 06:40 .gitignore
drwxrwxr-x  2 user user  4096 Jan 28 06:40 libexec
-rw-rw-r--  1 user user  1092 Jan 28 06:40 LICENSE
-rw-rw-r--  1 user user   285 Jan 28 06:40 Makefile
drwxrwxr-x  9 user user  4096 Jan 28 06:40 plugins
drwxrwxr-x  3 user user  4096 Jan 28 06:40 pyenv.d
-rw-rw-r--  1 user user 12420 Jan 28 06:40 README.md
drwxrwxr-x  2 user user  4096 Jan 28 06:40 src
drwxrwxr-x  3 user user  4096 Jan 28 06:40 test
-rw-rw-r--  1 user user   139 Jan 28 06:40 .travis.yml
user@ubuntu:~/.pyenv$ cd bin
user@ubuntu:~/.pyenv/bin$ ls -l
total 4
lrwxrwxrwx 1 user user  16 Jan 28 06:40 pyenv -> ../libexec/pyenv
-rwxrwxr-x 1 user user 731 Jan 28 06:40 python-local-exec
user@ubuntu:~/.pyenv/bin$ 
12

The instructions are a bit misleading because .bash_profile is only sourced when Bash is started with the --login option (e.g. from the console or ssh). However, .profile is always used, so it makes sense to place environment changes there.

Add the following to ~/.profile:

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

Open a new terminal window and your PATH variable will be correct to run pyenv.

11
  • Hi logged in and logged out as instructed in the earlier forums, I did include the path user@ubuntu:~$ pwd /home/user # What is inside the .bash_profile export PATH="$HOME/user/.pyenv/bin:$PATH" eval "$(pyenv init -)" eval "$(pyenv virtualenv-init -)" Is there something I missed?
    – rey bilan
    Jan 28 '15 at 16:54
  • What happens when you run ~/.pyenv/bin/pyenv?
    – Ben Grimm
    Jan 28 '15 at 17:00
  • is this what you mean? user@ubuntu:~/.pyenv/bin$ pyenv No command 'pyenv' found, did you mean: Command 'p7env' from package 'libnss3-tools' (main) pyenv: command not found
    – rey bilan
    Jan 28 '15 at 17:04
  • Actually, the whole thing: ~/.pyenv/bin/pyenv. It's is not found with the bare name because the directory is not in your PATH, which you can verify using echo $PATH. The change to .bash_profile should have included it.
    – Ben Grimm
    Jan 28 '15 at 17:08
  • so the path should be this? user@ubuntu:~$ echo $PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games How can I edit below to reflect the correct path? export PATH="$HOME/user/.pyenv/bin:$PATH"
    – rey bilan
    Jan 28 '15 at 17:11
0

In the main folder (the one shown when you open the file explorer, or you can view the path with the pwd command in the console) use Ctrl H, and then find the file .bash_profile and add it at the end:

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

Instead of using pyenv you can follow the steps in below.

  1. After successfully installed pip in your Ubuntu machine run the following command:

    pip3 install virtualenv
    
  2. Once it is installed, check to verify that the installation has completed successfully:

    virtualenv --version
    

    If you get the output something similar 16.4.3 than you have successfully installed virtualenv.

  3. Now run the following command to create a directory called new-dir, or another name of your choice. Then navigate to the directory.

    mkdir new-dir
    cd new-dir
    
  4. Now create your virtual environment, named newENV or anything else:

    virtualenv newENV
    
  5. And activate the virtual environment

    . env/bin/activate
    
1
  • 1
    This doesn't answer the question. "Don't use pyenv" isn't an answer for "How do I solve this problem in pyenv?". Oct 24 '20 at 22:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.