Closed sassanh closed 8 years ago
Thanks for the report. What is the output of the command:
:py3 import pprint; pprint.pprint( sys.path )
in Neovim?
Thanks for quick reply, this is the output:
['/Users/sassanharadji/.config/nvim/plugged/jedi-vim',
'/Users/sassanharadji/.virtualenvs/x/lib/python3.5/site-packages/Babel-2.4.0.dev0-py3.5.egg',
'/Users/sassanharadji/.virtualenvs/x/lib/python35.zip',
'/Users/sassanharadji/.virtualenvs/x/lib/python3.5',
'/Users/sassanharadji/.virtualenvs/x/lib/python3.5/plat-darwin',
'/Users/sassanharadji/.virtualenvs/x/lib/python3.5/lib-dynload',
'/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5',
'/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/plat-darwin',
'/Users/sassanharadji/.virtualenvs/x/lib/python3.5/site-packages',
'_vim_path_',
'/Users/sassanharadji/.config/nvim/plugged/vim-virtualenv/autoload']
And the output of:
:py3 from distutils import sysconfig; print( sysconfig.get_python_lib( standard_lib = True ) )
?
/Users/sassanharadji/.virtualenvs/x/bin/../lib/python3.5
Ok, applying os.path.normpath
on this line should fix your issue. I am just a little surprised that get_python_lib
returns a path with /../
in it. Which tool are you using to create your virtual environment? I can't reproduce this kind of path with the virtualenv
package from pip.
Anyway, I'll send a PR to fix this.
It didn't fix the issue, value of standard_library_path
after than line is "/Users/sassanharadji/.virtualenvs/x/lib/python2.7" but this directory does not exist, the one that exists is "/Users/sassanharadji/.virtualenvs/x/lib/python3.5" which is for python 3.5.
I guess ycm is not running with py3, seems like it's running with py.
Then what is the output of the two previous commands with py
instead of py3
?
First one:
[u'/Users/sassanharadji/.config/nvim/plugged/YouCompleteMe/third_party/ycmd/third_party/OmniSharpServer',
u'/Users/sassanharadji/.config/nvim/plugged/YouCompleteMe/third_party/ycmd/third_party/JediHTTP',
u'/Users/sassanharadji/.config/nvim/plugged/YouCompleteMe/third_party/ycmd/third_party/godef',
u'/Users/sassanharadji/.config/nvim/plugged/YouCompleteMe/third_party/ycmd/third_party/gocode',
u'/Users/sassanharadji/.config/nvim/plugged/YouCompleteMe/third_party/ycmd/third_party/frozendict',
u'/Users/sassanharadji/.config/nvim/plugged/YouCompleteMe/third_party/ycmd/third_party/bottle',
u'/Users/sassanharadji/.config/nvim/plugged/YouCompleteMe/third_party/ycmd/third_party/argparse',
u'/Users/sassanharadji/.config/nvim/plugged/YouCompleteMe/third_party/ycmd',
u'/Users/sassanharadji/.config/nvim/plugged/YouCompleteMe/third_party/retries',
u'/Users/sassanharadji/.config/nvim/plugged/YouCompleteMe/third_party/requests-futures',
u'/Users/sassanharadji/.config/nvim/plugged/YouCompleteMe/third_party/pythonfutures',
u'/Users/sassanharadji/.config/nvim/plugged/YouCompleteMe/python/ycm/../../third_party/ycmd',
u'/Users/sassanharadji/.config/nvim/plugged/YouCompleteMe/autoload/../python',
u'/Users/sassanharadji/.config/nvim/plugged/YouCompleteMe/third_party/ycmd/third_party/OmniSharpServer',
u'/Users/sassanharadji/.config/nvim/plugged/YouCompleteMe/third_party/ycmd/third_party/JediHTTP',
u'/Users/sassanharadji/.config/nvim/plugged/YouCompleteMe/third_party/ycmd/third_party/godef',
u'/Users/sassanharadji/.config/nvim/plugged/YouCompleteMe/third_party/ycmd/third_party/gocode',
u'/Users/sassanharadji/.config/nvim/plugged/YouCompleteMe/third_party/ycmd/third_party/frozendict',
u'/Users/sassanharadji/.config/nvim/plugged/YouCompleteMe/third_party/ycmd/third_party/bottle',
u'/Users/sassanharadji/.config/nvim/plugged/YouCompleteMe/third_party/ycmd/third_party/argparse',
u'/Users/sassanharadji/.config/nvim/plugged/YouCompleteMe/third_party/ycmd',
u'/Users/sassanharadji/.config/nvim/plugged/YouCompleteMe/third_party/retries',
u'/Users/sassanharadji/.config/nvim/plugged/YouCompleteMe/third_party/requests-futures',
u'/Users/sassanharadji/.config/nvim/plugged/YouCompleteMe/third_party/pythonfutures',
u'/Users/sassanharadji/.config/nvim/plugged/YouCompleteMe/python/ycm/../../third_party/ycmd',
u'/Users/sassanharadji/.config/nvim/plugged/YouCompleteMe/autoload/../python',
'/Users/sassanharadji/.virtualenvs/x/lib/python2.7/site-packages',
'/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',
'/Users/sassanharadji/Library/Python/2.7/lib/python/site-packages',
'/usr/local/lib/python2.7/site-packages',
'/usr/local/lib/python2.7/site-packages/gtk-2.0',
'/usr/local/lib/python2.7/site-packages/wx-3.0-osx_cocoa',
'/usr/local/lib/python2.7/site-packages',
'/usr/local/lib/python2.7/site-packages/gtk-2.0',
'/usr/local/lib/python2.7/site-packages/gtk-2.0',
'/usr/local/lib/python2.7/site-packages/wx-3.0-osx_cocoa',
'/Library/Python/2.7/site-packages',
'_vim_path_',
'/Users/sassanharadji/.config/nvim/plugged/vim-virtualenv/autoload',
'/Users/sassanharadji/.config/nvim/plugged/MatchTagAlways/autoload/../python']
Second one:
/Users/sassanharadji/.virtualenvs/x/lib/python2.7
@micbou I found that if I disable vim-virtualenv
plugin, everything works alright as before. Seems like the problem is with that plugin, though ycm didn't have any problems with it till the latest version.
I can reproduce your issue with the vim-virtualenv
plugin. I've sent PR https://github.com/Valloric/ycmd/pull/579 to fix the issue.
Note that the :VirtualEnvDeactivate
command from vim-virtualenv
plugin remove paths that were added by YCM in sys.path
so it may break YCM. Use with care. See issue https://github.com/jmcantrell/vim-virtualenv/issues/53.
Thanks following this up with me, your pr and info.
I'm having this issue still with the latest ycm (commit d38ffc54461963c4495fefdd8b0c3d706f72d957) I do not have vim-virtualenv
However, I have this bit in my .vimrc
"########################
"####### Python #########
"########################
" python with virtualenv support
py << EOF
import os
import sys
if 'VIRTUAL_ENV' in os.environ:
project_base_dir = os.environ['VIRTUAL_ENV']
activate_this = os.path.join(project_base_dir, 'bin/activate_this.py')
execfile(activate_this, dict(__file__=activate_this))
EOF
let python_highlight_all=1
let g:ycm_python_binary_path = '/usr/local/bin/python'
seeing this code (that I blindly pasted from some SO post :) ) I can see that me forcing the python path to the brew installed python (important to not use python 3 for me) is a bit inconsistent with the virtualenv setup. I don't know if that could explain my issue (does not seem so, if I remove it I get the same result. does not work. But works with the patch)
I did not quite follow the end of your discussion but I have for the moment successfully applied @micbou patch from there
Issue Prelude
Please complete these steps and check these boxes (by putting an
x
inside the brackets) before filing your issue:vim --version
.:YcmDebugInfo
.:YcmToggleLogs stderr
.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
Vim version:
OS X El Capitan
After updating to latest version ycm, when I run vim in a virtualenv I get this error:
The virtualenv is using python3 and I guess it's the problem. YCM is trying to read "python2-7" libraries in the lib folder of the python3 in the virtualenv.