The wrong python interpreter is called

前端 未结 6 552

I updated my python interpreter, but I think the old one is still called. When I check for the version I get:

$ python -V
Python 3.0.1

But

6条回答
  •  时光取名叫无心
    2020-12-30 08:47

    Firstly, the recommended shebang line is:

    #!/usr/bin/env python
    

    This will make sure the python interpreter that is invoked when you ./foo.py is the same interpreter that is invoked when you invoke python from the command line.

    From your description, I suspect that if you did:

    which python
    

    It would not give you /usr/bin/python. It would give you something else, which is where the python 3 interpreter lives. You can either modify your shebang line to the above, or replace the path to the python interpreter with the path returned by which.

提交回复
热议问题