How to make python3.2 interpreter the default interpreter in debian

后端 未结 5 1006
走了就别回头了
走了就别回头了 2021-02-05 09:38

I got both python2 and python3 installed in my debian machine. But when i try to invoke the python interpreter by just typing \'python\' in bash, python2 pops up and not python3

相关标签:
5条回答
  • 2021-02-05 10:04

    Well, you can simply create a virtualenv with the python3.x using this command:

    virtualenv -p <path-to-python3.x> <virtualenvname>

    0 讨论(0)
  • 2021-02-05 10:07

    using command:

        update-alternatives --config python
    

    Might Work However On My System(I have Python2&3 Installed As Well) It Gives Me An Error Saying No Alternatives For Python...

    0 讨论(0)
  • 2021-02-05 10:11

    Others have adviced you about the possible drawbacks, so, on the issue at hand:

    ln -s $(which python3) /usr/local/bin/python
    
    0 讨论(0)
  • 2021-02-05 10:13

    btw, if you are using bash or running from the shell, and you normally include at the top of the file the following line:

    #!/usr/bin/python

    then you can change the line to instead be:

    #!/usr/bin/python3

    That is another way to have pythonX run instead of the default (where X is 2 or 3).

    0 讨论(0)
  • 2021-02-05 10:21

    the only somehow safe way would be to use an alias in your shell, by placing

    alias python=python3
    

    into your ~/.profile or ~/.bashrc...

    this way the system scripts depending on python being python2 won't be affected.

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