Python-mode: Can not set g:pymode_python='python3'

Created on 9 Jun 2014  路  9Comments  路  Source: python-mode/python-mode

Can not set g:pymode_python='python3'
Then I run pymode#troubleshooting#test()

Error detected while processing function pymode#troubleshooting#test..pymode#init:
line    9:
E319: Sorry, the command is not available in this version: python3 import sys, vim
line   10:
E319: Sorry, the command is not available in this version: python3 sys.path.insert(0, vim.eval('a:plugin_root'))
line   11:
E319: Sorry, the command is not available in this version: python3 sys.path = vim.eval('a:paths') + sys.path
Error detected while processing /home/stevenfrog/.vim/bundle/python-mode/autoload/pymode/virtualenv.vim:
line    3:
E319: Sorry, the command is not available in this version: python3 from pymode.virtualenv import enable_virtualenv
Error detected while processing function pymode#troubleshooting#test..pymode#breakpoint#init:
line   15:
E319: Sorry, the command is not available in this version: python3 << EOF
line   17:
E492: Not an editor command: from imp import find_module
line   19:
E110: Missing ')'
E15: Invalid expression: ('pudb', 'ipdb'):
line   20:
E488: Trailing characters:     try:
line   28:
E170: Missing :endfor
Error detected while processing function pymode#troubleshooting#test:
line   43:
E319: Sorry, the command is not available in this version: python3 << EOF
line   44:
E492: Not an editor command: import vim
"path))" [New File]
Cannot open file "path))"
line   45:
E480: No match: command('let l:output = %s' % repr(sys
line   46:
E492: Not an editor command: EOF
line   47:
E121: Undefined variable: output
E116: Invalid arguments for function append
Pymode diagnostic
===================
VIM:703, OS: Linux, multi_byte:1, pymode: 0.8.0, python: python3


VIM python paths:
-----------------

Pymode variables:
-------------------
let pymode = 1
let pymode_breakpoint = 1
let pymode_breakpoint_bind = '<leader>b'
let pymode_doc = 1
let pymode_doc_bind = 'K'
let pymode_folding = 0
let pymode_indent = 1
let pymode_lint = 1
let pymode_lint_checkers = ['pyflakes', 'pep8', 'mccabe']
let pymode_lint_cwindow = 1
let pymode_lint_ignore = ''
let pymode_lint_message = 1
let pymode_lint_on_fly = 0
let pymode_lint_on_write = 0
let pymode_lint_select = ''
let pymode_lint_signs = 0
let pymode_motion = 1
let pymode_options = 1
let pymode_paths = []
let pymode_quickfix_maxheight = 6
let pymode_quickfix_minheight = 3
let pymode_rope = 0
let pymode_run = 1
let pymode_run_bind = '<leader>r'
let pymode_trim_whitespaces = 1
let pymode_virtualenv = 1
let pymode_virtualenv_enabled = ''
let pymode_virtualenv_path = ''

Most helpful comment

I am getting these same errors. I installed vim on Mac OSX and homebrew:

$ brew install vim --with-python3

I am using Miniconda Python 3. Miniconda Python 2 works fine.

I will see if the errors go away if I use a brew-installed python 3 instead.

All 9 comments

Does your VIM have python3 support?

I am getting these same errors. I installed vim on Mac OSX and homebrew:

$ brew install vim --with-python3

I am using Miniconda Python 3. Miniconda Python 2 works fine.

I will see if the errors go away if I use a brew-installed python 3 instead.

OK, I am now able to successfully use python-mode with vim and Python3 (Miniconda 3). I took the following steps on Mac OSX 10.9:

  • Install python3 with homebrew: brew install python3
  • Make sure the python3 points to your homebrewed python (NOT your miniconda python).
$ which python
/usr/local/bin/python3
  • Install vim with homebrew
$ brew install vim --with-python3
  • Install miniconda 3.

The key here is to make sure that vim is configured to use the homebrew Python 3 and not the miniconda Python 3.

EDIT: Fix typo: "I am not able..." --> "I am now able..."

@sloria Please clarify which python you think you're using. You mention that things started working after doing brew install python3. But you also imply you're using the python3 from the Anaconda miniconda environment. That doesn't make any sense as the Homebrew installed ViM isn't going to use those libraries without a lot of hacking. I think you're conflating two different environments.

As for the symptoms reported by @stevenfrog those are exactly what I would expect if the ViM he's using was not linked against python3. The output of vim --version would be helpful.

@krader1961 Sorry for my lack of clarity. python-mode will work when vim is built using Homebrew's python 3 binary. It will _not_ work if built with Miniconda's python3 (without--as you said--a lot of hacking).
Therefore, I made sure that the python3 command in my path pointed to the Homebrew python _before installing vim_.

I did this simply by

  1. Renaming ~/miniconda (which gets added to your path when you install Miniconda) to ~/miniconda-bak;
  2. Running brew install vim --with-python3, so that vim gets configured with my brew-installed python 3; then
  3. Renaming ~/miniconda-bak back to ~/miniconda

Thanks, I will try it later. Because Python 2, 3 puzzle me a lot.
I need more time to solve them.

Thanks for u all.

Thanks for the clarification, @sloria. The problem you describe and the process you used to workaround it is why I don't add the miniconda bin dir to my path automatically. Instead I have these zsh functions to make it easy to add/remove conda dirs to my PATH:

con () {
    source ~/conda/bin/activate ${1:-root}
}

coff () {
    typeset -a _path
    typeset _p
    for _p in $path
    do
        if [[ $_p != $HOME/conda/* ]]
        then
            _path+=$_p
        fi
    done
    path=($_path)
    unset CONDA_DEFAULT_ENV
}

@krader1961 That's a nifty trick. Thanks for that!

Thanks, I will try it later. Because Python 2, 3 puzzle me a lot.
I need more time to solve them.

Thanks for u all.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AdibMurshed picture AdibMurshed  路  10Comments

12kleingordon34 picture 12kleingordon34  路  3Comments

jabbalaci picture jabbalaci  路  8Comments

lyneca picture lyneca  路  4Comments

pieterdd picture pieterdd  路  4Comments