How to check all versions of python installed on osx and centos

前端 未结 9 1864
予麋鹿
予麋鹿 2021-01-31 07:46

I just started setting up a centos server today and noticed that the default version of python on centos is set to 2.6.6. I want to use python 2.7 instead. I googled around and

相关标签:
9条回答
  • 2021-01-31 08:00

    Find out which version of Python is installed by issuing the command python --version: $ python --version Python 2.7.10

    If you see something like this, Python 2.7 is your default version. You can also see if you have Python 3 installed:

    $ python3 --version
    Python 3.7.2
    

    If you also want to know the path where it is installed, you can issue the command "which" with python and python3:

    $ which python
    /usr/bin/python
    
    $ which python3
    /usr/local/bin/python3
    
    0 讨论(0)
  • 2021-01-31 08:03

    It depends on your default version of python setup. You can query by Python Version:

    python3 --version //to check which version of python3 is installed on your computer
    python2 --version // to check which version of python2 is installed on your computer
    python --version // it shows your default Python installed version.
    
    0 讨论(0)
  • 2021-01-31 08:03

    COMMAND: python --version && python3 --version

    OUTPUT:

    Python 2.7.10
    Python 3.7.1

    ALIAS COMMAND: pyver

    OUTPUT:

    Python 2.7.10
    Python 3.7.1

    You can make an alias like "pyver" in your .bashrc file or else using a text accelerator like AText maybe.

    0 讨论(0)
  • 2021-01-31 08:06

    we can directly use this to see all the pythons installed both by current user and the root by the following: whereis python

    0 讨论(0)
  • 2021-01-31 08:15

    Use,

    yum list installed
    command to find the packages you installed.

    0 讨论(0)
  • 2021-01-31 08:15

    As someone mentioned in a comment, you can use which python if it is supported by CentOS. Another command that could work is whereis python. In the event neither of these work, you can start the Python interpreter, and it will show you the version, or you could look in /usr/bin for the Python files (python, python3 etc).

    0 讨论(0)
提交回复
热议问题