23

So here is my Ubuntu version:

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.2 LTS
Release:        18.04
Codename:       bionic

I'm trying to run the following command: pyenv install 3.6.2 but i get the error:

Command 'pyenv' not found, did you mean:
  command 'pyvenv' from deb python3-venv
  command 'p7env' from deb libnss3-tools 

I've searched and this post (Ubuntu 14.04 - Python 3.4 - pyenv: command Not Found) states Ubuntu 14.04 and below use Python 2 be default so one has to use virtualenv instead, but why does my 18.04 Ubuntu not recognize the command?

notMyName
  • 690
  • 2
  • 6
  • 17

1 Answers1

71

First see if you have the curl already installed in your machine using the command:

$ curl --version

If you don't have, install the curl using:

$ sudo apt-get install curl

After that install the pyenv using the command:

$curl https://pyenv.run | bash

And after installation update your bashrc adding the lines:

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

Finally Reload the bashrc:

$ source ~/.bashrc

I think will work fine after that. If you installed the pyenv before, look up at you bashrc to confirm if you added the lines above and reload the bashrc again.

Community
  • 1
  • 1
Ircbarros
  • 945
  • 8
  • 15
  • I'm new to editing the .bashrc, do I just add those commands to the top of the file or does it have to go somewhere? – notMyName Jul 05 '20 at 16:39
  • 1
    Sorry for the delay! Every time will put something on the bashrc you should put at the bottom. Remenber to run the bash as root also ($ gedit ./bashrc), save the file and run the ($ source ~/.bashrc) – Ircbarros Jul 05 '20 at 18:09
  • 3
    in my Ubuntu 18.04 I had to change the 3rd line added in ~/.bashrc for: eval "$(pyenv virtualenv-init --path)" – Josep Alsina Jun 30 '21 at 13:47
  • 1
    These didn't work for me on 18.04. I have to use [the answer](https://stackoverflow.com/a/67779866/1786351) from this similar question. – J.X.Weiss Nov 12 '21 at 14:06
  • 1
    These `export`/`eval` commands are not shown in the `pyenv-installer` repo installation instructions. Where did you come up with these steps? – Mike B Aug 25 '22 at 05:56
  • Does anyone know why this doesn't persist after a new terminal session? – elgreco Jul 29 '23 at 07:21