Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jedi-vim not use Conda environment #907

Closed
lkhphuc opened this issue Feb 4, 2019 · 12 comments
Closed

Jedi-vim not use Conda environment #907

lkhphuc opened this issue Feb 4, 2019 · 12 comments

Comments

@lkhphuc
Copy link

lkhphuc commented Feb 4, 2019

Issue

Jedi-vim knows python in my conda env, but not use it. Instead it just use the base conda environment.
However it does use python in environment created by venv module.

Previously it worked OK for all env created with venv or conda, I'm currently on the latest version of jedi-vim.

Steps to reproduce

I create a new environment with conda create -n pytorch python=3.7 and installed pytorch.
Jedi knows about the environment but does not use it, so I can not autocomplete it with deoplete.

Output of “:verbose JediDebugInfo”

#### Jedi-vim debug information

##### jedi-vim version

 - jedi-vim git version: f367497
 - jedi git submodule status:  bd1010bbd2693f189ff780eb21fc4294071cb280 pythonx/jedi (v0.13.1)
 - parso git submodule status:  a2b153e3c13c41ead7682e6891a51ec20d58d9b1 pythonx/parso (v0.3.2)

##### Global Python

Using Python version 3 to access Jedi.
 - global sys.version: `3.7.2 (default, Dec 29 2018, 00:00:04), [Clang 4.0.1 (tags/RELEASE_401/final)]`
 - global site module: `/Users/phucle/miniconda3/lib/python3.7/site.py`

##### Jedi

 - path: `/Users/phucle/.local/share/nvim/plugged/jedi-vim/pythonx/jedi/jedi/__init__.py`
 - version: 0.13.1

##### Jedi environment: <SameEnvironment: 3.7.2 in /Users/phucle/miniconda3>

 - executable: /Users/phucle/miniconda3/bin/python
 - sys_path:
    - `/Users/phucle/miniconda3/lib/python37.zip`
    - `/Users/phucle/miniconda3/lib/python3.7`
    - `/Users/phucle/miniconda3/lib/python3.7/lib-dynload`
    - `/Users/phucle/miniconda3/lib/python3.7/site-packages`

##### Known environments

 - <Environment: 3.7.2 in /Users/phucle/miniconda3/envs/pytorch> (/Users/phucle/miniconda3/envs/pytorch/bin/python3.7) ==>> This should be the executable of jedi-vim.
 - <Environment: 2.7.15 in /usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7> (/usr/local/opt/python@2/bin/python2.7)

Create env with venv

If I create a new environment using python -m venv myenv, jedi recognize and use the environment:

#### Jedi-vim debug information

##### jedi-vim version

 - jedi-vim git version: f367497
 - jedi git submodule status:  bd1010bbd2693f189ff780eb21fc4294071cb280 pythonx/jedi (v0.13.1)
 - parso git submodule status:  a2b153e3c13c41ead7682e6891a51ec20d58d9b1 pythonx/parso (v0.3.2)

##### Global Python

Using Python version 3 to access Jedi.
 - global sys.version: `3.7.2 (default, Dec 29 2018, 00:00:04), [Clang 4.0.1 (tags/RELEASE_401/final)]`
 - global site module: `/Users/phucle/miniconda3/lib/python3.7/site.py`

##### Jedi

 - path: `/Users/phucle/.local/share/nvim/plugged/jedi-vim/pythonx/jedi/jedi/__init__.py`
 - version: 0.13.1

##### Jedi environment: <Environment: 3.7.2 in /Users/phucle/github/venv>

 - executable: /Users/phucle/github/venv/bin/python
 - sys_path:
    - `/Users/phucle/miniconda3/lib/python37.zip`
    - `/Users/phucle/miniconda3/lib/python3.7`
    - `/Users/phucle/miniconda3/lib/python3.7/lib-dynload`
    - `/Users/phucle/github/venv/lib/python3.7/site-packages`

##### Known environments

 - <Environment: 3.7.2 in /Users/phucle/github/venv> (/Users/phucle/github/venv/bin/python)
 - <Environment: 3.7.2 in /Users/phucle/miniconda3> (/Users/phucle/miniconda3/bin/python3.7)
 - <Environment: 2.7.15 in /usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7> (/usr/local/opt/python@2/bin/python2.7)

##### Settings

@lkhphuc
Copy link
Author

lkhphuc commented Feb 6, 2019

I did a check. From this commit onward (2a43448) jedi doesn't use my activated conda-env as executable any more.

Prior to this commit, jedi-vim use my activated conda-env as executable, but if no conda-env is activated (using root conda env), jedi-vim does not recognize the root conda-env.

@lkhphuc
Copy link
Author

lkhphuc commented Feb 11, 2019

Apparently Jedi only check environment in $VIRTUAL_ENV, so my solution for now is:
export VIRTUAL_ENV=$CONDA_PREFIX

@blueyed
Copy link
Collaborator

blueyed commented Feb 11, 2019

Is $CONDA_PREFIX similar to $VIRTUAL_ENV in this regard?

@lkhphuc
Copy link
Author

lkhphuc commented Feb 11, 2019

The environment var of conda is not well documented, but it appears to be the case here.

[I] ✘130 ➜ conda deactivate
[N] ➜ echo $CONDA_PREFIX
/Users/phucle/miniconda3
[I] ➜ conda activate pytorch
[N] ➜ echo $CONDA_PREFIX
/Users/phucle/miniconda3/envs/pytorch

This project use $CONDA_PREFIX to find virtual environment in addition to $VIRTUAL_ENV: intake/intake@73be37e#diff-cad0d0e903d312c7329edb300804bf4cR54
This comment too: conda/conda#2764 (comment)

@shanest
Copy link

shanest commented Nov 14, 2019

Just wanted to confirm that this solution worked for me too, for getting Jedi to use my active conda environment. I added to my .vimrc:

let $VIRTUAL_ENV = $CONDA_PREFIX

But it seems like this should be handled by jedi

@davidhalter
Copy link
Owner

If it helps you guys, I'm happy to discuss a pull request in Jedi that does this. It's probably pretty easy to do. Essentially it's another if.

Here's an example, @roxma did this already for a Jedi fork: https://github.com/ncm2/ncm2-jedi/pull/20/files (@roxma or @shanest it would be nice if you guys could test this on Jedi master and PR this).

@shanest
Copy link

shanest commented Nov 14, 2019

Thanks; I'll take a look at this and make a PR soon!

@astier
Copy link
Contributor

astier commented Dec 9, 2019

Would be great if this could be fixed.

@shanest
Copy link

shanest commented Dec 16, 2019

Does pull request 1440 work for you? That fixed this issue for me :)

davidhalter/jedi#1440

@astier
Copy link
Contributor

astier commented Dec 16, 2019

Sorry I don't use conda anymore.

@lkhphuc
Copy link
Author

lkhphuc commented Dec 16, 2019

Thank you very much, it fixed my issue.

@lkhphuc lkhphuc closed this as completed Dec 16, 2019
@aalok-sathe
Copy link

I don't think it works any longer. I added let $VIRTUAL_ENV = $CONDA_PREFIX to my .vimrc.
Here's the debug info:

verbose JediDebugInfo

Jedi-vim debug information

jedi-vim version
  • jedi-vim git version: 0.11.0-19-g7ac81cb
  • jedi git submodule status: 8ef2ce232cebf6f30b41b28b2677d84666a97d55 pythonx/jedi (v0.18.0-40-g8ef2ce2)
  • parso git submodule status: ef90bba3b3d4310c345885a1368dbfc8937765a3 pythonx/parso (v0.8.1-1-gef90bba)
Global Python

Using Python version 3 to access Jedi.
Error when trying to import vim: Vim(python3):E837: This Vim cannot execute :py3 after using :python
python3 failed to run, likely a Python config issue.

Settings
  omnifunc=pythoncomplete#Complete
        Last set from ~/.local/share/vim/vim82/ftplugin/python.vim line 44
  completeopt=menuone,longest,preview
        Last set from ~/.vim/bundle/jedi-vim/plugin/jedi.vim line 36

:version

VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Jul 22 2021 13:02:25)
Included patches: 1-3201
Compiled by asathe@node045
Huge version with GTK2 GUI.  Features included (+) or not (-):
+acl               +clipboard         +dnd               +gettext           +listcmds          -mouse_sysmouse    +postscript        -sound             +termresponse      +vreplace
+arabic            +cmdline_compl     -ebcdic            -hangul_input      +localmap          +mouse_urxvt       +printer           +spell             +textobjects       +wildignore
+autocmd           +cmdline_hist      +emacs_tags        +iconv             -lua               +mouse_xterm       +profile           +startuptime       +textprop          +wildmenu
+autochdir         +cmdline_info      +eval              +insert_expand     +menu              +multi_byte        +python/dyn        +statusline        +timers            +windows
-autoservername    +comments          +ex_extra          +ipv6              +mksession         +multi_lang        +python3/dyn       -sun_workshop      +title             +writebackup
-autoservername    +comments          +ex_extra          +ipv6              +mksession         +multi_lang        +python3/dyn       -sun_workshop      +title             +writebackup
+balloon_eval      +conceal           +extra_search      +job               +modify_fname      -mzscheme          +quickfix          +syntax            +toolbar           +X11
+balloon_eval_term +cryptv            -farsi             +jumplist          +mouse             +netbeans_intg     +reltime           +tag_binary        +user_commands     -xfontset
+browse            +cscope            +file_in_path      +keymap            +mouseshape        +num64             +rightleft         -tag_old_static    +vartabs           +xim
++builtin_terms    +cursorbind        +find_in_path      +lambda            +mouse_dec         +packages          -ruby              -tag_any_white     +vertsplit         +xpm
+byte_offset       +cursorshape       +float             +langmap           -mouse_gpm         +path_extra        +scrollbind        -tcl               +virtualedit       +xsmp_interact
+channel           +dialog_con_gui    +folding           +libcall           -mouse_jsbterm     -perl              +signs             +termguicolors     +visual            +xterm_clipboard
+cindent           +diff              -footer            +linebreak         +mouse_netterm     +persistent_undo   +smartindent       +terminal          +visualextra       -xterm_save
+clientserver      +digraphs          +fork()            +lispindent        +mouse_sgr         +popupwin          -sodium            +terminfo          +viminfo
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants