pythonpyenv

how do i go back to my system python using pyenv in Ubuntu


i installed pyenv and switched to python 3.6.9 (using pyenv global 3.6.9). How do i go back to my system python? Running pyenv global system didnt work


Solution

  • Your system Python might be /usr/bin/python or /usr/bin/python3. You have a couple options:

    1. Execute that Python interpreter directly:
    /usr/bin/python --version
    

    If you want to run it from a script and you're on a *nix machine, put

    #!/usr/bin/python
    

    at the top of the file, then give it execute permissions (chmod +x my-script.py) and run it directly: ./my-script.py.

    1. Turn off pyenv's path hacks. This could mean removing the eval "$(pyenv init -)" from your ~/.bashrc or ~/.bash_profile and loading a new shell.

    2. Use the pyenv register plugin - https://github.com/doloopwhile/pyenv-register (or use/build something similar). Here's a portion of the README

    Installation:

    git clone https://github.com/doloopwhile/pyenv-register.git $(pyenv root)/plugins/pyenv-register  # clone plugin
    exec "$SHELL"  # reload shell
    

    Usage:

    pyenv register /usr/bin/python
    pyenv versions