Problems while opening Python files #179

Open
cjjojoba opened this Issue Oct 14, 2012 · 12 comments

Comments

Projects
None yet
7 participants

When I open Python files, I get following errors (I see them for ~1 sec and then the file is opened)

"quad_tree.py" 57L, 1629C
Error detected while processing function pymode#Option:
line 8:
E121: Undefined variable: g:pymode_syntax
E121: Undefined variable: g:pymode_options
E121: Undefined variable: g:pymode_doc
E121: Undefined variable: g:pymode_lint
E121: Undefined variable: g:pymode_rope
E121: Undefined variable: g:pymode_run
E121: Undefined variable: g:pymode_breakpoint
E121: Undefined variable: g:pymode_utils_whitespaces
E121: Undefined variable: g:pymode_folding
Error detected while processing /Users/MYUSERNAME/.spf13-vim-3/.vim/bundle/python-mode/after/ftplugin/py
thon.vim:
line 2:
E121: Undefined variable: g:pymode_rope
E15: Invalid expression: g:pymode && g:pymode_rope && g:pymode_rope_vim_completion
Error detected while processing /Users/MYUSERNAME/.spf13-vim-3/.vim/bundle/python-mode/after/indent/pyth
on.vim:
line 1:
E121: Undefined variable: g:pymode_indent
E15: Invalid expression: pymode#Default('b:pymode_indent', 1) || !g:pymode_indent
Error detected while processing function pymode#Option:
line 8:
E121: Undefined variable: g:pymode_syntax

Operating System: MacOS X 10.7.4
vim --version:

VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Feb 21 2012 19:37:18)
Compiled by root@apple.com
Normal version without GUI. Features included (+) or not (-):
-arabic +autocmd -balloon_eval -browse +builtin_terms +byte_offset +cindent
-clientserver -clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments
-conceal +cryptv +cscope +cursorbind +cursorshape +dialog_con +diff +digraphs
-dnd -ebcdic -emacs_tags +eval +ex_extra +extra_search -farsi +file_in_path
+find_in_path +float +folding -footer +fork() -gettext -hangul_input +iconv
+insert_expand +jumplist -keymap -langmap +libcall +linebreak +lispindent
+listcmds +localmap -lua +menu +mksession +modify_fname +mouse -mouseshape
-mouse_dec -mouse_gpm -mouse_jsbterm -mouse_netterm -mouse_sysmouse
+mouse_xterm +multi_byte +multi_lang -mzscheme +netbeans_intg -osfiletype
+path_extra -perl +persistent_undo +postscript +printer -profile -python
-python3 +quickfix +reltime -rightleft -ruby +scrollbind +signs +smartindent
-sniff +startuptime +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"
fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -D_FORTIFY_SOURCE=0 -Iproto -DHAVE_CONFIG_H -arch i386 -arch x86_64 -g -Os -pipe
Linking: gcc -arch i386 -arch x86_64 -o vim -lncurses

lenciel commented Oct 18, 2012

I think the error message means your vim is not compiled with python support.
What is the output when you run:

$ vim --version | grep python | echo $?

I am also having this issue. In response to lenciel, when I run that I get this:
-bash: $: command not found
0

phretor commented Oct 30, 2012

I also experience this error: My ViM has python support:

vim --version | grep python          
+path_extra -perl +persistent_undo +postscript +printer -profile -python 
-python3 +quickfix +reltime -rightleft -ruby +scrollbind +signs +smartindent

lenciel commented Oct 30, 2012

I solved this problem by compiling vim myself.
@oreillygarrett You should first check which vim you are running...
@phretor I think the -python -python3 is telling you that you don't have python installed....when you see +python you win (quite funny and I don't understand why the version command prints something out with a - when it's not there). A more reliable way to check whether you have python util with vim is: run !py print(sys.version) inside your vim. This command is really useful when you have multiple versions of python installed and after you build vim with one of them, you can make sure vim is picking up the correct python installation.

harijay commented Nov 7, 2012

I had to not use the homebrew installed python on OSX , but then build vim using the homebrew recipe here (https://gist.github.com/721952)
So Briefly

  1. brew unlink python
  2. brew remove mercurial ( in case it was built against the brew installed python)
  3. brew install mercurial
  4. brew install https://gist.github.com/raw/721952/843b390acb9f86226133ce3e94ed99ee485c494f/vim.rb --HEAD --enable-interp=python --with-features=huge

Then after that I stopped getting the pymode errors , even after I linked back the brew python

phretor commented Nov 8, 2012

I'm afraid that that would "break" more than mercurial. For instance, I guess that all the virtualenvs created against the original python.

Collaborator

johntyree commented Jan 15, 2013

@phretor, according to the output above, your vim doesn't have python support.

-python should be +python.

You'll have to rebuild it for certain, but maybe it will work with your system python install. I think apple includes a notoriously old and crappy one with OSX though, so who knows.

phretor commented Jan 15, 2013

Yes @johntyree, it doesn't have python support. Unfortunately, I still doubt that the solution proposed above by @harijay wouldn't break the python build that I already installed on my system via brew (and the dependent virtualenvs).

Collaborator

johntyree commented Jan 15, 2013

That might be true, but you can also try just building vim against the version of python that you already have.

phretor commented Jan 25, 2013

Different issue, but same outcome:

  • removed brewed python
  • brewed python
  • brewed vim
  • removed spf13-vim
[phretor@ecto:~]
% curl http://j.mp/spf13-vim3 -L -o - | sh
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1323  100  1323    0     0   1085      0  0:00:01  0:00:01 --:--:--  3469
Thanks for installing spf13-vim
backing up current vim config
cloning spf13-vim
Cloning into '/Users/phretor/.spf13-vim-3'...
remote: Counting objects: 1932, done.
remote: Compressing objects: 100% (1049/1049), done.
remote: Total 1932 (delta 926), reused 1804 (delta 820)
Receiving objects: 100% (1932/1932), 2.21 MiB | 464 KiB/s, done.
Resolving deltas: 100% (926/926), done.
setting up symlinks
ln: /Users/phretor/.vimrc.fork: File exists
ln: /Users/phretor/.vimrc.bundles.fork: File exists
Installing Vundle
Cloning into '/Users/phretor/.vim/bundle/vundle'...
remote: Counting objects: 2428, done.
remote: Compressing objects: 100% (1567/1567), done.
remote: Total 2428 (delta 820), reused 2369 (delta 769)
Receiving objects: 100% (2428/2428), 293.14 KiB | 137 KiB/s, done.
Resolving deltas: 100% (820/820), done.
update/install plugins using Vundle
Vim: Warning: Input is not from a terminal
[phretor@ecto:~]
% vim
Error detected while processing /Users/phretor/.spf13-vim-3/.vim/bundle/python-mode/plugin/pymode.vim:
line  129:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/phretor/.spf13-vim-3/.vim/bundle/python-mode/pylibs/pymode/auto.py", line 2, in <module
    from pylibs.autopep8 import fix_file
  File "/Users/phretor/.spf13-vim-3/.vim/bundle/python-mode/pylibs/autopep8.py", line 43, in <module>
    import tempfile
  File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/tempfile.py", line 34, in <module>
    from random import Random as _Random
  File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/random.py", line 47, in <module>
    from os import urandom as _urandom
ImportError: cannot import name urandom
line  248:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/phretor/.spf13-vim-3/.vim/bundle/python-mode/pylibs/ropevim.py", line 4, in <module>
    import tempfile
  File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/tempfile.py", line 34, in <module>
    from random import Random as _Random
  File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/random.py", line 47, in <module>
    from os import urandom as _urandom
ImportError: cannot import name urandom
Press ENTER or type command to continue
[phretor@ecto:~]
% which python
/usr/local/bin/python
[phretor@ecto:~]
% python 
Python 2.7.3 (default, Jan 25 2013, 01:56:40) 
[GCC 4.2.1 Compatible Apple Clang 3.1 (tags/Apple/clang-318.0.58)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from random import Random as _Random
>>> from os import urandom as _urandom
>>> import tempfile
>>> 
Collaborator

jrobeson commented Jul 1, 2014

is this at all related to #176 ?

Collaborator

johntyree commented Jul 1, 2014

Certainly looks like it. I gave up on py-mode quite awhile ago so I can't offer much help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment