Loading ...
Sorry, an error occurred while loading the content.

Re: specifying python interpreter for vim7

Expand Messages
  • Chris Fonnesbeck
    ... I was testing it by importing a module that is installed in 2.4.1, but not ... gives me an ImportError saying that the module doesnt exist, while it
    Message 1 of 12 , Apr 4, 2006
    • 0 Attachment
      On 4/3/06, Benji Fisher <benji@...> wrote:
      >
      > On Mon, Apr 03, 2006 at 12:47:34PM -0400, Chris Fonnesbeck wrote:
      > > On 4/3/06, Benji Fisher <benji@...> wrote:
      >
      > How did you test this? Specifically, are you testing the version
      > of python that was linked to vim, or are you testing the version that
      > you get from something like
      >
      > :!python -V
      >

      I was testing it by importing a module that is installed in 2.4.1, but not
      in 2.3.5:

      :python from numpy import *

      gives me an ImportError saying that the module doesnt exist, while it
      imports fine from the python shell.

      Thanks,
      C.

      --
      Chris Fonnesbeck + Atlanta, GA + http://trichech.us
    • Benji Fisher
      ... First, I would try ... (and look for the compilation flags at the end). If you see Python.framework/Versions/2.3 several times, then I will be convinced
      Message 2 of 12 , Apr 4, 2006
      • 0 Attachment
        On Tue, Apr 04, 2006 at 09:15:33AM -0400, Chris Fonnesbeck wrote:
        > On 4/3/06, Benji Fisher <benji@...> wrote:
        > >
        > > On Mon, Apr 03, 2006 at 12:47:34PM -0400, Chris Fonnesbeck wrote:
        > > > On 4/3/06, Benji Fisher <benji@...> wrote:
        > >
        > > How did you test this? Specifically, are you testing the version
        > > of python that was linked to vim, or are you testing the version that
        > > you get from something like
        > >
        > > :!python -V
        > >
        >
        > I was testing it by importing a module that is installed in 2.4.1, but not
        > in 2.3.5:
        >
        > :python from numpy import *
        >
        > gives me an ImportError saying that the module doesnt exist, while it
        > imports fine from the python shell.

        First, I would try

        :python import sys
        :python print sys.path

        Even simpler:

        :version

        (and look for the compilation flags at the end).

        If you see "Python.framework/Versions/2.3" several times, then I will be
        convinced that Vim.app was somehow linked with python 2.3.5 despite the
        messages you got from the configure script. In this case, the next step
        is to have a look at src/auto/config.log for clues, and maybe the
        configure script itself, to see what went wrong.

        From the tests you have described so far, it looks to me as though
        you might actually have linked with python 2.4.1, but you need to tweak
        sys.path, perhaps via the PYTHONPATH environment variable.

        HTH --Benji Fisher
      • Chris Fonnesbeck
        ... Here is the sys.path [ /Users , /System/Library/Frameworks/Python.framework/Versions/2.3/lib/python23.zip , /System/Library/Frameworks/Python.fr
        Message 3 of 12 , Apr 5, 2006
        • 0 Attachment
          On 4/4/06, Benji Fisher <benji@...> wrote:
          >
          > On Tue, Apr 04, 2006 at 09:15:33AM -0400, Chris Fonnesbeck wrote:
          > > On 4/3/06, Benji Fisher <benji@...> wrote:
          > > >
          > > > On Mon, Apr 03, 2006 at 12:47:34PM -0400, Chris Fonnesbeck wrote:
          > > > > On 4/3/06, Benji Fisher <benji@...> wrote:
          > > >
          > > > How did you test this? Specifically, are you testing the version
          > > > of python that was linked to vim, or are you testing the version that
          > > > you get from something like
          > > >
          > > > :!python -V
          > > >
          > >
          > > I was testing it by importing a module that is installed in 2.4.1, but
          > not
          > > in 2.3.5:
          > >
          > > :python from numpy import *
          > >
          > > gives me an ImportError saying that the module doesnt exist, while it
          > > imports fine from the python shell.
          >
          > First, I would try
          >
          > :python import sys
          > :python print sys.path
          >
          > Even simpler:
          >
          > :version
          >
          > (and look for the compilation flags at the end).
          >
          > If you see "Python.framework/Versions/2.3" several times, then I will be
          > convinced that Vim.app was somehow linked with python 2.3.5 despite the
          > messages you got from the configure script. In this case, the next step
          > is to have a look at src/auto/config.log for clues, and maybe the
          > configure script itself, to see what went wrong.
          >
          > From the tests you have described so far, it looks to me as though
          > you might actually have linked with python 2.4.1, but you need to tweak
          > sys.path, perhaps via the PYTHONPATH environment variable.
          >

          Here is the sys.path

          ['/Users',
          '/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python23.zip',
          '/System/Library/Frameworks/Python.fr
          amework/Versions/2.3/lib/python2.3',
          '/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/plat-darwin',
          '/
          System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/plat-mac',
          '/System/Library/Frameworks/Python.framework
          /Versions/2.3/lib/python2.3/plat-mac/lib-scriptpackages',
          '/System/Library/Frameworks/Python.framework/Versions/2.3/lib/pytho
          n2.3/lib-tk',
          '/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/lib-dynload',
          '/System/Library/Framewor
          ks/Python.framework/Versions/2.3/lib/python2.3/site-packages',
          '/System/Library/Frameworks/Python.framework/Versions/2.3/Extr
          as/lib/python',
          '/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/Numeric',
          '/System/Libr
          ary/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/PyObjC',
          '/Library/Python/2.3', '/System/Library/Fra
          meworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/py2app',
          '/System/Library/Frameworks/Python.framework/Versi
          ons/2.3/lib/python2.3/site-packages/wx-2.6-mac-ansi']

          and here is :version

          VIM - Vi IMproved 7.0c08 BETA (2006 Apr 3, compiled Apr 5 2006 09:13:29)
          MacOS X (unix) version
          Compiled by chris@...
          Big version with Carbon GUI. Features included (+) or not (-):
          +arabic +autocmd -balloon_eval +browse ++builtin_terms +byte_offset +cindent
          -clientserver +clipboard +cmdline_compl
          +cmdline_hist +cmdline_info +comments +cryptv -cscope +cursorshape
          +dialog_con_gui +diff +digraphs -dnd -ebcdic +emacs_tags
          +eval +ex_extra +extra_search +farsi +file_in_path +find_in_path +folding
          -footer +fork() -gettext -hangul_input +iconv
          +insert_expand +jumplist +keymap +langmap +libcall +linebreak +lispindent
          +listcmds +localmap +menu +mksession +modify_fname
          +mouse -mouseshape +mouse_dec -mouse_gpm -mouse_jsbterm +mouse_netterm
          +mouse_xterm +multi_byte +multi_lang -mzscheme
          -netbeans_intg -osfiletype +path_extra -perl +postscript +printer -profile
          +python +quickfix +rightleft -ruby +scrollbind
          +signs +smartindent -sniff +statusline -sun_workshop +syntax +tag_binary
          +tag_old_static -tag_any_white -tcl +terminfo
          +termresponse +textobjects +title -toolbar +user_commands +vertsplit
          +virtualedit +visual +visualextra +viminfo +vreplace
          +wildignore +wildmenu +windows +writebackup -X11 -xfontset -xim -xsmp
          -xterm_clipboard -xterm_save
          system vimrc file: "$VIM/vimrc"
          user vimrc file: "$HOME/.vimrc"
          user exrc file: "$HOME/.exrc"
          system gvimrc file: "$VIM/gvimrc"
          user gvimrc file: "$HOME/.gvimrc"
          system menu file: "$VIMRUNTIME/menu.vim"
          fall-back for $VIM: "/Applications/Vim.app/Contents/Resources/vim"
          Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_MAC -fno-common
          -fpascal-strings -Wall -Wno-unknown-pragmas -mdyna
          mic-no-pic -pipe -I. -Iproto -DMACOS_X_UNIX -no-cpp-precomp
          -I/Developer/SDKs/MacOSX10.4u.sdk/Developer/Headers/FlatCarbon -
          O -fno-strength-reduce -Wall -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch
          i386 -arch ppc -I/Library/Frameworks/Python.
          framework/Versions/2.4/include/python2.4
          Linking: gcc -L/usr/local/lib -isysroot /Developer/SDKs/MacOSX10.4u.sdk
          -arch i386 -arch ppc -o Vim -framework Carbon
          -lncurses -liconv -framework Python

          You are right; I may have to play with the python path, but it seems strange
          that 2.3.5 ends up on the sys.path. I dont actually have a PYTHONPATH
          variable defined in my environment at the moment; but python 2.4.1 is on my
          PATH.

          C.

          --
          Chris Fonnesbeck + Atlanta, GA + http://trichech.us
        • Chris Fonnesbeck
          ... I tried setting the PYTHONHOME variable: PYTHONHOME=/Library/Frameworks/Python.framework/Versions/2.4 (which should do the trick on OSX) then logged out
          Message 4 of 12 , Apr 5, 2006
          • 0 Attachment
            On 4/5/06, Chris Fonnesbeck <fonnesbeck@...> wrote:
            >
            > On 4/4/06, Benji Fisher <benji@...> wrote:
            >
            > >
            > > From the tests you have described so far, it looks to me as though
            > > you might actually have linked with python 2.4.1, but you need to tweak
            > > sys.path, perhaps via the PYTHONPATH environment variable.
            > >
            >
            >
            > You are right; I may have to play with the python path, but it seems
            > strange that 2.3.5 ends up on the sys.path. I dont actually have a
            > PYTHONPATH variable defined in my environment at the moment; but python
            > 2.4.1 is on my PATH.
            >
            > <http://trichech.us>
            >

            I tried setting the PYTHONHOME variable:

            PYTHONHOME=/Library/Frameworks/Python.framework/Versions/2.4

            (which should do the trick on OSX) then logged out and in again, but the
            problem persists.

            C.

            --
            Chris Fonnesbeck + Atlanta, GA + http://trichech.us
          • Benji Fisher
            ... Where did you set the PYTHONHOME variable? If you are starting Vim.app from the Finder (or, I think, if you start it using the open command) then vim does
            Message 5 of 12 , Apr 5, 2006
            • 0 Attachment
              On Wed, Apr 05, 2006 at 09:36:27AM -0400, Chris Fonnesbeck wrote:
              > On 4/5/06, Chris Fonnesbeck <fonnesbeck@...> wrote:
              > >
              > > You are right; I may have to play with the python path, but it seems
              > > strange that 2.3.5 ends up on the sys.path. I dont actually have a
              > > PYTHONPATH variable defined in my environment at the moment; but python
              > > 2.4.1 is on my PATH.
              >
              > I tried setting the PYTHONHOME variable:
              >
              > PYTHONHOME=/Library/Frameworks/Python.framework/Versions/2.4
              >
              > (which should do the trick on OSX) then logged out and in again, but the
              > problem persists.

              Where did you set the PYTHONHOME variable? If you are starting
              Vim.app from the Finder (or, I think, if you start it using the open
              command) then vim does not inherit environment variables from your login
              shell. You can try calling the executable from a Terminal window,

              $ /Applications/Vim.app/Contents/MacOS/Vim -g

              or you can try

              :let $PYTHONHOME = '/Library/Frameworks/Python.framework/Versions/2.4'

              when vim is running, or from your vimrc file, or use the suggestion
              under

              :help mac-faq

              to set environment variables as in a login shell.

              HTH --Benji Fisher
            • Chris Fonnesbeck
              ... Interestingly, when I do this something very odd happens. It now cites the 2.4 directory, but continues to look for python 2.3! It looks like something is
              Message 6 of 12 , Apr 5, 2006
              • 0 Attachment
                On 4/5/06, Benji Fisher <benji@...> wrote:
                >
                > On Wed, Apr 05, 2006 at 09:36:27AM -0400, Chris Fonnesbeck wrote:
                > > On 4/5/06, Chris Fonnesbeck <fonnesbeck@...> wrote:
                > > >
                > > > You are right; I may have to play with the python path, but it seems
                > > > strange that 2.3.5 ends up on the sys.path. I dont actually have a
                > > > PYTHONPATH variable defined in my environment at the moment; but
                > python
                > > > 2.4.1 is on my PATH.
                > >
                > > I tried setting the PYTHONHOME variable:
                > >
                > > PYTHONHOME=/Library/Frameworks/Python.framework/Versions/2.4
                > >
                > > (which should do the trick on OSX) then logged out and in again, but the
                > > problem persists.
                >
                > Where did you set the PYTHONHOME variable? If you are starting
                > Vim.app from the Finder (or, I think, if you start it using the open
                > command) then vim does not inherit environment variables from your login
                > shell. You can try calling the executable from a Terminal window,
                >
                > $ /Applications/Vim.app/Contents/MacOS/Vim -g
                >
                > or you can try
                >
                > :let $PYTHONHOME = '/Library/Frameworks/Python.framework/Versions/2.4'


                Interestingly, when I do this something very odd happens. It now cites the
                2.4 directory, but continues to look for python 2.3! It looks like something
                is hard-wired somewhere:

                ['/Users/chris/Downloads',
                '/Library/Frameworks/Python.framework/Versions/2.4/lib/python23.zip',
                '/Library/Frameworks/Python.
                framework/Versions/2.4/lib/python2.3/',
                '/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.3/plat-darwin',
                '/Libr
                ary/Frameworks/Python.framework/Versions/2.4/lib/python2.3/plat-mac',
                '/Library/Frameworks/Python.framework/Versions/2.4/lib/
                python2.3/plat-mac/lib-scriptpackages',
                '/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.3/lib-tk',
                '/Library/F
                rameworks/Python.framework/Versions/2.4/lib/python2.3/lib-dynload']




                --
                Chris Fonnesbeck + Atlanta, GA + http://trichech.us
              • Benji Fisher
                ... [snip] ... Perhaps the problem is that the linking option is simply -framework Python . The compilation flags specify python2.4. See the comments in
                Message 7 of 12 , Apr 7, 2006
                • 0 Attachment
                  On Wed, Apr 05, 2006 at 09:22:06AM -0400, Chris Fonnesbeck wrote:
                  >
                  > VIM - Vi IMproved 7.0c08 BETA (2006 Apr 3, compiled Apr 5 2006 09:13:29)
                  > MacOS X (unix) version
                  > Compiled by chris@...
                  > Big version with Carbon GUI. Features included (+) or not (-):
                  [snip]
                  > Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_MAC -fno-common
                  > -fpascal-strings -Wall -Wno-unknown-pragmas -mdyna
                  > mic-no-pic -pipe -I. -Iproto -DMACOS_X_UNIX -no-cpp-precomp
                  > -I/Developer/SDKs/MacOSX10.4u.sdk/Developer/Headers/FlatCarbon -
                  > O -fno-strength-reduce -Wall -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch
                  > i386 -arch ppc -I/Library/Frameworks/Python.
                  > framework/Versions/2.4/include/python2.4
                  > Linking: gcc -L/usr/local/lib -isysroot /Developer/SDKs/MacOSX10.4u.sdk
                  > -arch i386 -arch ppc -o Vim -framework Carbon
                  > -lncurses -liconv -framework Python
                  >
                  > You are right; I may have to play with the python path, but it seems strange
                  > that 2.3.5 ends up on the sys.path. I dont actually have a PYTHONPATH
                  > variable defined in my environment at the moment; but python 2.4.1 is on my
                  > PATH.

                  Perhaps the problem is that the linking option is simply
                  "-framework Python". The compilation flags specify python2.4.

                  See the comments in src/Makefile , starting with

                  # - If you do not trust the automatic configuration code, then inspect
                  # auto/config.h and auto/config.mk, before starting the actual build
                  # phase. If possible edit this Makefile, rather than auto/config.mk --
                  # especially look at the definition of VIMLOC below. Note that the
                  # configure phase overwrites auto/config.mk and auto/config.h again.

                  You can probably get it to link with the right version of python by
                  hacking one of the auto/config.* files or src/Makefile (setting LDFLAGS
                  somewhere).

                  I suppose the most direct method is to run "gcc -L/usr/local/lib
                  -isysroot ..." from the shell.

                  If this works, please let us know. Someone (probably Bram) can
                  probably fix the autoconf/Makefile stuff so that it does not require a
                  hack.

                  If you manage to link with the correct version of python and still
                  have problems, this may be more of a python problem than a Mac problem.
                  You might get more help from the general vim users' list (vim@...)
                  than this one. I will be off-line from later today until Monday.

                  HTH --Benji Fisher
                Your message has been successfully submitted and would be delivered to recipients shortly.