Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[tlug] How to Set Default Version of Python



On Mon, 25 Jan 2021 03:05:46 +0100 (CET), raroof@example.com wrote:

> python3 --version says: 3.8.5sudo python says:  Python 2.7.18 (default, Aug  4 2020, 11:16:42) 
> [GCC 9.3.0] on linux2
> 
> Wow. So is there a way I can change the default? 

To more directly answer the question you asked:

     Yes!

as shown below with pyenv mentioned in earlier email.

    j@j:~$ pyenv versions
      system
      3.8.3
      3.8.7
      3.9.0
    * 3.9.1 (set by PYENV_VERSION environment variable)
    j@j:~$ PYENV_VERSION=3.8.3
    j@j:~$ pyenv versions
      system
    * 3.8.3 (set by PYENV_VERSION environment variable)
      3.8.7
      3.9.0
      3.9.1
    j@j:~$ python3
    Python 3.8.3 (default, Jun 19 2020, 19:53:48)
    [Clang 11.0.0 (clang-1100.0.33.16)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>>
    j@j:~$ python
    Python 3.8.3 (default, Jun 19 2020, 19:53:48)
    [Clang 11.0.0 (clang-1100.0.33.16)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>>
    j@j:~$ PYENV_VERSION=3.9.1
    j@j:~$ pyenv versions
      system
      3.8.3
      3.8.7
      3.9.0
    * 3.9.1 (set by PYENV_VERSION environment variable)
    j@j:~$ python3
    Python 3.9.1 (default, Jan 14 2021, 21:52:16)
    [Clang 12.0.0 (clang-1200.0.32.28)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> python
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    NameError: name 'python' is not defined
    >>>
    j@j:~$ python
    Python 3.9.1 (default, Jan 14 2021, 21:52:16)
    [Clang 12.0.0 (clang-1200.0.32.28)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>>
    j@j:~$

By the way, below shows what it took to install another version of Python
before doing the above.

    j@j:~$ pyenv versions 
      system 
      3.8.3 
      3.9.0 
    * 3.9.1 (set by PYENV_VERSION environment variable) 
    j@j:~$ pyenv install 3.8.7 
    python-build: use openssl@1.1 from homebrew 
    python-build: use readline from homebrew 
    Downloading Python-3.8.7.tar.xz... 
    -> https://www.python.org/ftp/python/3.8.7/Python-3.8.7.tar.xz 
    Installing Python-3.8.7... 
    python-build: use readline from homebrew 
    python-build: use zlib from xcode sdk 
    Installed Python-3.8.7 to /Users/jep/.pyenv/versions/3.8.7 
 
    j@j:~$ pyenv versions 
      system 
      3.8.3 
      3.8.7 
      3.9.0 
    * 3.9.1 (set by PYENV_VERSION environment variable) 
    j@j:~$  



Home | Main Index | Thread Index