简体   繁体   中英

How do I run a python script using a specific interpreter?

I'm having problems with pygame as documented here: PyGame bogging down linux?

After a bit of searching around and brainstorming I realized it may be because I'm using python2.7 instead of 2.6 which PyGame was designed for.

How do I run my script using the 2.6 interpreter instead of 2.7 (which seems to be the default).

Thanks

OS - Ubuntu

Python installs different binaries (and links to binaries):

  • python links to the system's standard Python (2) version
  • python3 links to the system's standard Python 3 version
  • python2 links to the system's standard Python 2 version
  • python2.7 is the Python 2.7 interpreter
  • python2.6 is the Python 2.6 interpreter

So just use it like this:

python2.6 file.py

Note that you need to have Python 2.6 installed of course.

First install the alternative Python using apt-get and second, run with full path to the interpreter.

Also, on ubuntu you should be able to use something like python2.6 script.py .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM