Youcompleteme: 'encoding' is an invalid keyword argument on python files

Created on 28 Jul 2016  ยท  7Comments  ยท  Source: ycm-core/YouCompleteMe

Issue Prelude

Please complete these steps and check these boxes (by putting an x inside
the brackets) _before_ filing your issue:

  • [x] I have read and understood YCM's CONTRIBUTING document.
  • [x] I have read and understood YCM's CODE_OF_CONDUCT document.
  • [x] I have read and understood YCM's README, especially the
    Frequently Asked Questions section.
  • [x] I have searched YCM's issue tracker to find issues similar to the one I'm
    about to report and couldn't find an answer to my problem. (Example Google
    search.
    )
  • [x] If filing a bug report, I have included the output of vim --version.
  • [x] If filing a bug report, I have included the output of :YcmDebugInfo.
  • [x] If filing a bug report, I have included the output of
    :YcmToggleLogs stderr.
  • [x] If filing a bug report, I have included which OS (including specific OS
    version) I am using.
  • [x] If filing a bug report, I have included a minimal test case that reproduces
    my issue.
  • [x] I understand this is an open-source project staffed by volunteers and
    that any help I receive is a selfless, heartfelt _gift_ of their free time. I
    know I am not entitled to anything and will be polite and courteous.
  • [x] I understand my issue may be closed if it becomes obvious I didn't
    actually perform all of these steps.

Thank you for adhering to this process! It ensures your issue is resolved
quickly and that neither your nor our time is needlessly wasted.

Issue Details

With opening any python file I get

YouCompleteMe unavailable: 'encoding' is an invalid keyword argument for this function

To reproduce it just open python file even empty or new buffer with .py extension.

I tried to reinstall YouComleteMe totally by removing folder from ~/.vim/bundle and installing with vim +BundleInstall and then ./install.sh --clang-completer. But it didn't help.

Currently I use vim from brew, but I tried to use MacVim too. There is the same issue.

Similar issue: https://github.com/Valloric/YouCompleteMe/issues/2024

Can't call :YcmDebugInfo and :YcmToggleLogs stderr because of E492: Not an editor command: .... Also with opening python files in the temp folder (in my case /var/folders/16/dcxbn15x0pjfm7wt7b8mm52r0000gn/T/ycm_temp logs do not appear). With opening any other file logs appears.

~โฏ vim --version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jul 21 2016 12:31:02)
MacOS X (unix) version
Included patches: 1-2085
Compiled by Homebrew
Huge version without GUI.  Features included (+) or not (-):
+acl             +file_in_path    -mouse_sysmouse  -tag_any_white
+arabic          +find_in_path    +mouse_urxvt     -tcl
+autocmd         +float           +mouse_xterm     +termguicolors
-balloon_eval    +folding         +multi_byte      +terminfo
-browse          -footer          +multi_lang      +termresponse
++builtin_terms  +fork()          -mzscheme        +textobjects
+byte_offset     -gettext         +netbeans_intg   +timers
+channel         -hangul_input    +num64           +title
+cindent         +iconv           +packages        -toolbar
-clientserver    +insert_expand   +path_extra      +user_commands
+clipboard       +job             +perl            +vertsplit
+cmdline_compl   +jumplist        +persistent_undo +virtualedit
+cmdline_hist    +keymap          +postscript      +visual
+cmdline_info    +langmap         +printer         +visualextra
+comments        +libcall         +profile         +viminfo
+conceal         +linebreak       +python          +vreplace
+cryptv          +lispindent      -python3         +wildignore
+cscope          +listcmds        +quickfix        +wildmenu
+cursorbind      +localmap        +reltime         +windows
+cursorshape     -lua             +rightleft       +writebackup
+dialog_con      +menu            +ruby            -X11
+diff            +mksession       +scrollbind      -xfontset
+digraphs        +modify_fname    +signs           -xim
-dnd             +mouse           +smartindent     -xsmp
-ebcdic          -mouseshape      +startuptime     -xterm_clipboard
+emacs_tags      +mouse_dec       +statusline      -xterm_save
+eval            -mouse_gpm       -sun_workshop    -xpm
+ex_extra        -mouse_jsbterm   +syntax
+extra_search    +mouse_netterm   +tag_binary
+farsi           +mouse_sgr       +tag_old_static
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  fall-back for $VIM: "/usr/local/share/vim"
Compilation: clang -c -I. -Iproto -DHAVE_CONFIG_H   -DMACOS_X_UNIX  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: clang   -L. -fstack-protector -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib  -L/usr/local/lib -o vim        -lncurses -liconv -framework Cocoa   -mmacosx-version-min=10.11 -fstack-protector-strong -L/usr/local/lib  -L/usr/local/Cellar/perl/5.24.0_1/lib/perl5/5.24.0/darwin-thread-multi-2level/CORE -lperl -lm -lutil -lc -F/usr/local/Cellar/python/2.7.12/Frameworks -framework Python   -lruby.2.3.0 -lobjc -L/usr/local/Cellar/ruby/2.3.1/lib
~โฏ sw_vers
ProductName:    Mac OS X
ProductVersion: 10.11.6
BuildVersion:   15G31

Most helpful comment

Thanks. This is a compatibility issue between YCM and the flake8-vim plugin. The former uses python-future for Python 2 and 3 support while the latter uses pies. These two packages don't work well together. Unfortunately, I don't see an easy way to prevent this. I suggest to use syntastic instead of flake8-vim or ask the flake8-vim author to not depend on pies.

All 7 comments

Traceback (most recent call last):
  File "<string>", line 24, in <module>
  File "/Users/gw/.vim/bundle/YouCompleteMe/autoload/../python/ycm/setup.py", line 49, in SetUpYCM
    base.LoadJsonDefaultsIntoVim()
  File "/Users/gw/.vim/bundle/YouCompleteMe/autoload/../python/ycm/base.py", line 54, in LoadJsonDefaultsIntoVim
    defaults = user_options_store.DefaultOptions()
  File "/Users/gw/.vim/bundle/YouCompleteMe/python/ycm/../../third_party/ycmd/ycmd/user_options_store.py", line 55, in DefaultOptions
    options = json.loads( ReadFile( settings_path ) )
  File "/Users/gw/.vim/bundle/YouCompleteMe/python/ycm/../../third_party/ycmd/ycmd/utils.py", line 57, in ReadFile
    with open( filepath, encoding = 'utf8' ) as f:
TypeError: 'encoding' is an invalid keyword argument for this function

git status inthird_party/ycmd is HEAD detached at 8b2f78a

What is the output of :py import pprint; pprint.pprint( sys.path ) in Vim?

Sorry, didn't see any notifications from this thread.

[u'/Users/gw/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/waitress',
 u'/Users/gw/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/tern_runtime',
 u'/Users/gw/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/requests',
 u'/Users/gw/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/racerd',
 u'/Users/gw/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/OmniSharpServer',
 u'/Users/gw/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/JediHTTP',
 u'/Users/gw/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/godef',
 u'/Users/gw/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/gocode',
 u'/Users/gw/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/frozendict',
 u'/Users/gw/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/bottle',
 u'/Users/gw/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/argparse',
 u'/Users/gw/.vim/bundle/YouCompleteMe/third_party/ycmd',
 u'/Users/gw/.vim/bundle/YouCompleteMe/third_party/retries',
 u'/Users/gw/.vim/bundle/YouCompleteMe/third_party/requests-futures',
 u'/Users/gw/.vim/bundle/YouCompleteMe/third_party/pythonfutures',
 u'/Users/gw/.vim/bundle/YouCompleteMe/python/ycm/../../third_party/ycmd',
 u'/Users/gw/.vim/bundle/YouCompleteMe/autoload/../python',
 '/Users/gw/.vim/bundle/flake8-vim/ftplugin/python/pies',
 '/Users/gw/.vim/bundle/flake8-vim/ftplugin/python/frosted',
 '/Users/gw/.vim/bundle/flake8-vim/ftplugin/python/autopep8',
 '/Users/gw/.vim/bundle/flake8-vim/ftplugin/python/pep8',
 '/Users/gw/.vim/bundle/flake8-vim/ftplugin/python/mccabe',
 '/Users/gw/.vim/bundle/flake8-vim/ftplugin/python',
 '/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python27.zip',
 '/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
 '/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
 '/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
 '/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
 '/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
 '/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old',
 '/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload',
 u'/Users/gw/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/python-future/src',
 '/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages',
 '/Library/Python/2.7/site-packages',
 '_vim_path_']

Thanks. This is a compatibility issue between YCM and the flake8-vim plugin. The former uses python-future for Python 2 and 3 support while the latter uses pies. These two packages don't work well together. Unfortunately, I don't see an easy way to prevent this. I suggest to use syntastic instead of flake8-vim or ask the flake8-vim author to not depend on pies.

Thanks a lot, autocompleting works without flake8.

you can use codecs module in python for this.
import codecs
f = codecs.open('file_name.txt', 'r', 'UTF-8')

Was this page helpful?
0 / 5 - 0 ratings