Change Python interpreter

Help
MySTiK
2006-12-06
2013-04-26
  • MySTiK

    MySTiK - 2006-12-06

    Hi all

    I am currently using Xubuntu and I would like to know whether it is possible or not to allow DrPython to choose one specific Python interpreter. It chooses 2.4 by default but I would like it to use 2.5 instead. (Note that I can switch to Python 2.5 completely and DrPython will use it since it uses /usr/bin/python. But I would like it to use /usr/bin/python2.5 instead and still have 2.4 on /usr/bin/python). I already tried "#! /usr/bin/env python2.5 and #! /usr/bin/python2.5" in the files but it did not work. Any ideas?

    Thank u very much!

     
    • Franz Steinhaeusler

      Hello,

      sorry, at the moment not.
      Do you want to open a python prompt with another python exectutable or run a program with it.

      For Python prompt you could perhaps write a DrScript:

      savedpythexec = DrFrame.pythexec
      DrFrame.pythexec = <your python exec>
      DrFrame.OnPython(None) or DrFrame.ExecutePython()
      DrFrame.pythexec = savedpythexec

      and bind it to a key.

      The same perhaps (write an own script) to run the current file in a buffer.

       
    • ricolai

      ricolai - 2009-05-17

      Hi,
      the simplest solution is to launch DrPython with the desired version of Python

      but I had an idea:

      I modified the code of drpython.py in order to execute the script with the version given in the first line of the script (e.g. #!/usr/bin/python2.5 to force version 2.5 instead of the defaut one)

      After line 2425:
      it was originally

      else:
                  self.runcommand((self.pythexec + " -u " +  self.prefs.pythonargs + ' "' + self.txtDocument.filename + '"'  + largs), "Running " + filen, filen)                #patch: [ 1366679 ] Goto Line Should Not Display At Top Of Window

      I turned it into

              else:
                  test=open(self.txtDocument.filename)
                  ligne1=test.readline()
                  test.close()
                  if "/usr/bin/python" in ligne1:
                      self.pythexec=ligne1[2:] # normally, it's adequate
                  self.runcommand((self.pythexec + " -u " +  self.prefs.pythonargs + ' "' + self.txtDocument.filename + '"'  + largs), "Running " + filen, filen)                #patch: [ 1366679 ] Goto Line Should Not Display At Top Of Window
                  self.pythexec=sys.executable # to go back to the original executable

      hoping it may help (or even it might be integrated in DrPython, in a cleaner way, for example by some menu allowing you to choose the python version you want to use for a specific script)

      ricolai

       
    • Franz Steinhaeusler

      Should that patch go into drpyhton.py? Is that needed more times? One could read out the first line of current document (GetLine(0)) and compare it to the python path

       
  • dupoxy

    dupoxy - 2009-09-21

    this path should go into drpython.py for me and it leed's me to:
    does drpython support virtualenv  ?
    I could just creat a virtualenv install drpython in it (it should be on the pypi to make it really simple)like that I have the packages and  interpreter I need for the project I'm working on will not touching my system default.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks