Install python server for emacs-jedi

I am trying to install Jedi for emacs using the marmalade package manager, following the instructions here - http://tkf.imtqy.com/emacs-jedi/latest/ . The package manager installs Jedi along with its dependencies. But I can not install python server using:

Mx jedi:install-server 

because this command is not available even after restarting emacs after installing jedi. Only the following commands are available:

 Possible completions are: jedi:ac-setup jedi:complete jedi:dot-complete jedi:get-in-function-call jedi:goto-definition jedi:goto-definition-next jedi:goto-definition-pop-marker jedi:setup jedi:show-doc jedi:show-jedi-version jedi:start-dedicated-server jedi:stop-server jedi:toggle-debug-server 

My.emacs has the following:

 (autoload 'jedi:setup "jedi" nil t) (add-hook 'python-mode-hook 'jedi:setup) (setq jedi:complete-on-dot t) 

I am using emacs on Mac OS X.

In this current state, when I open any python file (I use python 2.7), I see that the following automatically appears in the minibuffer:

 deferred error : (error Server may raise an error : Traceback (most recent call last): File "/Users/t_nithyanandan/.emacs.d/elpa/jedi-0.1.2/jediepcserver.py", line 302, in <module> main() File "/Users/t_nithyanandan/.emacs.d/elpa/jedi-0.1.2/jediepcserver.py", line 298, in main jedi_epc_server(**vars(ns)) File "/Users/t_nithyanandan/.emacs.d/elpa/jedi-0.1.2/jediepcserver.py", line 210, in jedi_epc_server import_jedi() File "/Users/t_nithyanandan/.emacs.d/elpa/jedi-0.1.2/jediepcserver.py", line 249, in import_jedi import jedi ImportError: No module named jedi ) 

I tried installing jedi using other methods like el-get as well as manually, but they don't seem to even go that far. I see that the available Jedi commands are even smaller than the above.

Can someone help indicate what I am missing?

Thanks.

Edit: The main goal I would like to use Jedi is to use autocomplete functions for python programming, although I believe that Jedi has many powerful features. For this purpose a python server is needed or can I get around it? In the end, of course, I would like to take advantage of many more features in the Jedi.

+5
source share
2 answers

I managed to solve this problem thanks to the help of Chris and Sioheks from emacs-jedi github. Credit goes to them, tracing it to the Jedi version.

I am simply linking the discussion to emacs-jedi issue # 177 and inserting a workaround that I found, including other issues that I encountered along the way.

I used the Marmalade version, which installs a much older version. So I removed jedi and related dependencies. I installed my repository in MELPA and installed a much newer version of the Jedi. It made a team

 Mx jedi:install-server 

which was not before.

However, issuing this command gave an error

 python-environment--make-with-runner: Program named "virtualenv" does not exist. 

I made sure that I added the virtualenv location to PATH in my .bashrc. So I looked at emacs-jedi issue # 158 , which suggested installing exec-path-from-shell. I installed it from MELPA and added the lines

 (when (memq window-system '(mac ns)) (exec-path-from-shell-initialize)) 

following instructions.

Restarting Emacs with the above lines gave an error:

 Symbol function definition is void: exec-path-from-shell-initialize 

So, I looked at Autoload issue # 3 when developing exec-path-from-shell (a link to this can be found in the link for emacs-jedi issue # 177). Following one of the solutions, I restarted my computer, uninstalled and reinstalled exec-path-from-shell, which magically resolved the problem that existed before the reboot.

Now I checked emacs if virtualenv can be found using

 M-! which virtualenv 

He gave the correct location.

Then I ran:

 Mx jedi:install-server 

which now seemed to run without problems. The first time there were messages about creating a default virtual environment in

 /Users/XXX/.emacs.d/.python-environments 

Besides

 Running: pip install --upgrade /Users/XXX/.emacs.d/elpa/jedi-20140321.1323/...Done 

but in subsequent tests, a pip update message was displayed.

Seeing that the server was installed without problems, I closed and restarted Emacs and opened the python script file. When I started editing, I received these messages in minibuffers:

 Error (jedi): Failed to start Jedi EPC server. *** You may need to run "Mx jedi:install-server". *** This could solve the problem especially if you haven't run the command yet since Jedi.el installation or update and if the server complains about Python module imports. 

and

 auto-complete error: (error Server may raise an error. Use "Mx epc:pop-to-last-server-process-buffer RET" to see full traceback: /opt/local/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python: can't open file '/Users/XXX/.emacs.d/elpa/jedi-0.1.2/jediepcserver.py': [Errno 2] No such file or directory` ) 

Thus, I realized that I needed to execute the command:

 Mx jedi:install-server 

every time I run Emacs before opening any python file. Then I was finally able to see the autocomplete features available during editing.

Although I can run the above command manually each time, I wanted to automate it from my .emacs when starting Emacs. It turned out that I had the following line in my .emacs

 (setq jedi:server-command (list "python" "/Users/XXX/.emacs.d/elpa/jedi-0.1.2/jediepcserver.py")) 

After deleting this line in my .emacs the problem disappeared and now jedi is working.

+8
source

Marmalade currently contains jedi version 0.1.2 , but you are looking at the documentation for version 0.2.0alpha2 .

Documentation for version 0.1.2 contains various instructions

package.el (Marmalade or MELPA)

You can install Jedi.el using the package.el interface from Marmalade or MELPA . Since package.el does not support the installation of non-elisp packages, you need to manually install the Python part (see the next section).

And then in the next section, an important bit:

Install Jedi and python-epc on

  • make requirements (no root privileges needed) or
  • pip install -r requirements.txt if you want to determine where to install Python modules. To install it in the system directory, you must have root privileges (i.e. sudo ).

You should be able to do make requirements from the ~/.emacs.d/elpa/jedi-0.1.2/ , but something like pip install epc jedi should work too.

+1
source

Source: https://habr.com/ru/post/1203093/


All Articles