5

I'm using the Anaconda python framework. Anaconda has it's own virtual environment system, and it's not clear to me if virtualenv can be used safely with Anaconda.

Emacs Jedi seems to require virtualenv. Is it used at "runtime" or is it used only during installation? Is it possible to use Jedi without having virtualenv installed? Can virtualenv be un-installed once Jedi installation is complete?

Is there some way to ask this question directly of the Jedi developers? (couldn't find a way)

garyp
  • 899
  • 7
  • 31
  • "Virtualbox"? Are you mixing a virtualization tool a la VMware with [a Python framework for installing packages without system privileges](http://virtualenv.org)? These are quite different things. – tripleee Feb 11 '14 at 14:57
  • Argh. I use Virtualbox, and my fingers slipped while typing. Editing now. Thanks. – garyp Feb 11 '14 at 20:48
  • The answer by user2053036 worked in my environment. But another problem come out, I think I'm not the only one who have meet this error: *cannot import name 'get_venv_path' from 'jedi.evaluate.sys_path' (d:\program_file\miniconda\envs\emacs-jedi\lib\site-packages\jedi\evaluate\sys_path.py)* I finally make this error disappear, by adding a method get_venv_path() to the sys_path.py shows up in the error。 def get_venv_path(sys_path): return [] this worked for me, though it may be not a good solution. – spider May 28 '19 at 03:51

3 Answers3

4

Is there some way to ask this question directly of the Jedi developers?

You can use their github issue tracker which lives here.

The emacs-jedi website states that virtualenv is optional so I guess jedi will work without it. If you can post how you are installing jedi or how you want to install it (manually, using el-get or some other way) then people here will be able to help you better.

UPDATE

Here is one way to install jedi manually without virtualenv

1) Install jedi from melpa. Do M-x list-packages, mark the package jedi by pressing I and then press X to install the package (this will install all the dependencies as far as elisp is concerned)

2) Then install the python dependencies, you can download the requirements.txt from here and then do pip install -r requirements.txt, this will install the python dependencies.

3) Add a python-mode hook to start jedi when you open python files, basically add the following to your init file

(autoload 'jedi:setup "jedi" nil t)
(add-hook 'python-mode-hook 'jedi:setup)

The above should setup jedi, if you face problems in any of the above steps do not hesitate to ask

UPDATE 2

Below are the steps to get emacs-jedi working with 'conda environment framework` (I used miniconda but this should work even with full conda installation)

1) Create a conda environment (for current example the environment is named emacs-jedi) by doing

conda create -n emacs-jedi python

2) Build the package for jedi, epc and sexpdata (required for for emacs-jedi)

a) Clone the conda-recipes repository

b) Build the required package by doing conda build /path/to/conda-recipies/<pkgname>

3) Switch to the environment created above by doing source activate emacs-jedi and install the packages built above by doing

conda install --use-local jedi sexpdata epc

--use-local is used to instruct conda to install from locally built packages

4) Finally instruct emacs to use this environment with jedi, this simply add the following to your init file

(eval-after-load "jedi"
    '(setq jedi:server-command (list "/path/to/emacs-jedi/bin/python" jedi:server-script)))
  • The site has detailed instructions for manual set-up. It seems that Virtualenv is only necessary if you want completely automatic installation via `el-get` (but it's perhaps a good idea even for a manual install). – tripleee Feb 11 '14 at 14:59
  • I do have jedi setup and working, but since garyp has explicitly asked for a non-virtualenv installation, I have provided one way to do so. And you are right using `virtualenv` IS a good idea. –  Feb 11 '14 at 15:02
  • The manual install that you suggest worked fine. Your method is covered in the Jedi docs, but I had misread the instructions. Concerning virtualenv: Anaconda comes with its own environment framework, and it's not clear that it can be used at the same time as virtualenv. It might be, but I'm not sure. I've used both virtualbox and conda environments, and I find for my purposes that conda seems more straightforward. It is, of course, less well known than virtualenv, and the developers are still tweaking it, I think. And the docs need improving, but I thought the same about virtualenv. – garyp Feb 13 '14 at 18:13
  • Hi, it seems that it is possible to use jedi with the anaconda environment framework. First you will need to find how you to install jedi in conda, [https://github.com/conda/conda-recipes] has a recipe for installing jedi. Once you have created a new conda environment and installed jedi in it, you can simply set `jedi:server-command` in emacs to the (`your/conda/python` `/path/to/emacs-jedi/jediepcserver.py`). Sorry for not providing concrete instructions (I do not use Anaconda) but these pointers might help. Do not hesitate to ask if you face any issues. –  Feb 14 '14 at 02:30
  • @garyp, I managed to get emacs-jedi to get working with conda environment, I have updated the answer. –  Feb 14 '14 at 03:37
  • 1
    Link to requirements dead. – The Unfun Cat Aug 07 '14 at 17:45
2

Jedi.el dev here. As of Jedi.el v0.2.0, virtualenv becomes the default and highly recommended. Manual installation is still supported but discouraged since you need to manually sync version of Jedi.el and Python modules. See:

I have no idea what anaconda is, but I suppose here that it has own environment. If it is just a wrapper of virtualenv then follow the instruction in the manual and use --virtual-env. If not, you can use --sys-path to tell Jedi.el about additional site-path. See:

First, you need to find anaconda-specific site-path. Run

python -c 'import sys; print(sys.path)'

in anaconda and find some anaconda-specific paths (I have no idea what it will be. But I guess it includes "anaconda" in the path). Then add these paths using --sys-path. See jedi:server-args document for the code.

tkf
  • 2,880
  • 15
  • 32
  • I don't know exactly how this relates to using jedi.el with anaconda/conda (other than not recommending it :) ). Do I need to by syncing something? I could not understand the links. Everything is currently working. If I don't sync will I eventually have problems? I find anaconda/conda easier to work with than virtualenv, so at the moment my priority is to keep things there. – garyp Mar 13 '14 at 22:39
  • If I start using some new feature of Python modules and update required version, you will be in trouble. As it is not recommended, not many people will be using manual method so it will be hard to get answer if you have some questions. – tkf Mar 13 '14 at 23:16
  • 1
    OK. I updated the answer. I was assuming that anaconda was a wrapper around virtualenv in the first answer. But even if it is not, you can always add sys.path using --sys-path to tell Jedi.el that you are using modules in there. BTW, if you have anything don't understand in the document, report in the tracker because it is *documentation bug* to have incomprehensible manual. – tkf Mar 13 '14 at 23:36
  • Great. Thank you very much. – garyp Mar 14 '14 at 00:54
0

Here is my hack to set the jedi:server-command variable:

(setq jedi:server-command
        `("python"
          ,(concat (file-name-directory
                   (buffer-file-name
                    (car
                     (find-definition-noselect 'jedi:setup nil))))
                  "jediepcserver.py")))
Jason Furtney
  • 171
  • 1
  • 4