How to use multiple versions of Python without uninstallation

前端 未结 15 1568
醉梦人生
醉梦人生 2021-02-05 14:11

I am faced with a unique situation, slightly trivial but painful.

I need to use Python 2.6.6 because NLTK is not ported to Python 3 (that\'s what I could gather).

15条回答
  •  情歌与酒
    2021-02-05 14:55

    You can specify the version you want in the shebang line. I just ran into this when a VM my Ops guy set up had Python 2.6 in /usr/bin/python2.6, and I needed 2.7 for a few features. He installed it for me at /usr/bin/python2.7.

    My old shebang:

    #!/usr/bin/env python
    

    stopped working, because /usr/bin/python was a link to /usr/bin/python2.6. What wound up fixing the problem, and working across Windows, Linux, and OSX, was changing the shebang to:

    #!/usr/bin/env python2.7
    

    It should work for any version, I believe.

提交回复
热议问题