pythonic-emacs / anaconda-mode Goto Github PK
View Code? Open in Web Editor NEWCode navigation, documentation lookup and completion for Python.
License: GNU General Public License v3.0
Code navigation, documentation lookup and completion for Python.
License: GNU General Public License v3.0
Please see #49 for an explanation; restoring the line sys.path.insert(0, '')
resolves the issue.
Hey I have my http_proxy envs set which seems to be causing issues with completion
Using a proxy for http...
Making url-show-status local to *http 127.0.0.1:3128* while let-bound!
anaconda-mode-view-doc: Can't find documentation
Missing module docstring (C0111)
Beginning of buffer [2 times]
Mark set
Company: An error occurred in auto-begin
Company: Back-end company-anaconda error "End of file during parsing" with args (candidates fire)
Company: An error occurred in auto-begin
Company: Back-end company-anaconda error "End of file during parsing" with args (candidates fire)
Making completion list...
Hi,
Anaconda mode looks very interesting. Could you give some motivation as to why a user should prefer it to Elpy (https://github.com/jorgenschaefer/elpy), which I am currently using. What are your unique strengths? To my untrained eye it looks like you cover very similar ground.
Thanks
P.S. I discovered you via a link from the jedi docs: http://jedi.jedidjah.ch/en/latest/
Hello,
I was having some problems with the installation and in the end I tried a simple command python anaconda_mode.py
for which I got the following result:
$ python anaconda_mode.py
Traceback (most recent call last):
File "/home/atlas/.emacs.d/elisp/anaconda-mode/anaconda_mode.py", line 2, in <module>
from jsonrpc import dispatcher, JSONRPCResponseManager
ImportError: cannot import name dispatcher
I just installed jsonrpc with sudo pip install jsonrpc
. Have you any idea what the problem could be?
Find usages result must return code snippet not line number duplication. The good point to fix this is jedi
it self.
Hello,
I have a jedi-mode, autocomplete, projectile setup right now.
And I want to change it to anaconda-mode, company-mode, projectile.
When I checked the code I saw that anaconda-mode has hardcoded integration to cask. But I want to use projectile instead. Is it possible to use projectile with anaconda-mode? I want to start anaconda server on projectile project root. So goto-source commands would work right.
Here is how I change the root in my current setup.
https://github.com/huseyinyilmaz/emacs-config/blob/master/lisp/user-init-jedi.el#L52-L56
Jedi provides goto_definitions
, goto_assignments
and usages
that each returns a list of definitions. I think we need a mode for navigating such a list. Below is the usages of script_method
. Definitions are grouped by module, inspired by occur.
You navigate up and down with n
and p
, and a preview is shown in other-window
. If you press enter or click a row, you jump to that location. When you jump, the current position is pushed to a stack so that you are able to navigate back.
goto_definitions
and goto_assignments
should immediately jump if there is just 1 candidate. M-.
should be bound to goto_definitions
, and we can have another key for goto_assignments
. I don't think goto_definitions
and goto_assignments
should be mixed.
What do you think @proofit404, is this a good idea? I have implemented some parts of this.
I get this when I try to use anaconda-go-to-definition :( Can you guide me on what information should I give to solve this? Running Emacs 24.4 Ubuntu 14.04
Some times silently anaconda_mode
fail to start and doesn't say user anything. Most times this happens because specified port already in use. Any way its necessary raise a error.
when open two emacs instances editing different python files, the emacs (actually the computer) will hang. The CPU is 100% used.
Hello - goto definition works great. I just can't figure this out, but how would I lookup a definition by searching for it by typing the name ? maybe integrated with helm.
In Atom or Sublime its easy to do cmd-shift-R, lookup the class name and go straight to the definition.
I've made an etags file for emacs, but its matching imports and usages. When I search in helm it doesn't know where the class def itself is.
Obviously jedi knows where the class def is (because goto definition works correctly)
So is this a command that anaconda-mode should implement ? Or should I look more at helm ?
Thanks for your help and for the package.
When I do M-.
it open the new buffer or position in the same window. Would be great if with C-u M-.
it open the new buffer in the other window, like in find-file-other-window
Trying to install this package from MELPA, emacs version: GNU Emacs 24.3.1 (i386-mingw-nt6.1.7600)
Compile log:
Leaving directory `c:/Users/dmishin/AppData/Roaming/.emacs.d/elpa/anaconda-mode-20140327.142'
Compiling file c:/Users/dmishin/AppData/Roaming/.emacs.d/elpa/anaconda-mode-20140327.142/anaconda-eldoc.el at Thu Mar 27 13:32:33 2014
Entering directory `c:/Users/dmishin/AppData/Roaming/.emacs.d/elpa/anaconda-mode-20140327.142/'
Compiling file c:/Users/dmishin/AppData/Roaming/.emacs.d/elpa/anaconda-mode-20140327.142/anaconda-mode-pkg.el at Thu Mar 27 13:32:33 2014
Compiling file c:/Users/dmishin/AppData/Roaming/.emacs.d/elpa/anaconda-mode-20140327.142/anaconda-mode.el at Thu Mar 27 13:32:33 2014
In anaconda-mode-do-request:
anaconda-mode.el:109:26:Warning: reference to free variable
`url-http-response-status'
Compiling file c:/Users/dmishin/AppData/Roaming/.emacs.d/elpa/anaconda-mode-20140327.142/company-anaconda.el at Thu Mar 27 13:32:33 2014
company-anaconda.el:26:1:Error: Cannot open load file: company
Add following sections to README:
Few first requests will always fail due to server initialization lag. Server must be started synchronously with emacs. Protect anaconda-mode-call
with and
function. This'll allow don't perform rpc calls on broken nodes.
http://val.markovic.io/articles/youcompleteme-as-a-server
https://github.com/Valloric/ycmd
I assume that the architecture is pretty similar to communicating with jedi, even simpler. Maybe transfer anaconda-mode's code to that is the fastest way to get it implemented.
Just in case you're interested :)
Question: does the name anaconda
has anything to do with the Python distribution Anaconda
and its tool conda
?
In anaconda-mode-python, python executable is hardcoded as "python" . This is not convinient, especially when you have python3 and python2 installed at the same time. I think it will be better if you change it to use python-shell-interpreter.
Anyway, thank you for this great mode. I like it.
I've had this issue recently after updating anaconda-mode
from melpa. My emacs hung when company-mode tries to auto complete with anaconda
, and I see message as following in minibar.
Blocking call to accept-process-output with quit inhibited.
I guess this is a regression as I saw previous discussion on this issue before. Below is backtrace log on toggle-debug-on-quit
.
Debugger entered--Lisp error: (quit)
anaconda-mode-bootstrap()
anaconda-mode-start()
anaconda-mode-call("complete")
anaconda-mode-complete()
company-anaconda-candidates()
company-anaconda(candidates #("fo" 0 2 (fontified nil)))
apply(company-anaconda (candidates #("fo" 0 2 (fontified nil))))
#[0 "\302 !\203��\303 \300\"\207\303\304 \300#\207" [(candidates #("fo" 0 2 (fontified nil))) company-backend functionp apply company--multi-backend-adapter] 4 "\n\n(fn)"]()
funcall(#[0 "\302 !\203��\303 \300\"\207\303\304 \300#\207" [(candidates #("fo" 0 2 (fontified nil))) company-backend functionp apply company--multi-backend-adapter] 4 "\n\n(fn)"])
company-call-backend-raw(candidates #("fo" 0 2 (fontified nil)))
company--fetch-candidates(#("fo" 0 2 (fontified nil)))
company-calculate-candidates(#("fo" 0 2 (fontified nil)))
#[0 "\n\203 �\nC\202\n��\211\205\245�\211@\300�9\204��\306�!\203<��9\2036��\307N\310=\2046��\307N?\205@�\311�!\205@��\312!\202@�\313�\312\"\240\210\300\242\203\236�\314\300\242!\203\230�\315\300\242!�\211�\301\316\f!\240\210\301\242:\204l�
\203\230�\317\320!\210\202\230�
\203t�\300\242��\2119\203\203�\321\322�!P��\202\211�\323\301\242@!\210\324\301\242!\210\325\326\327 \"\210\330\331!\210\332\333\301\242\"\210�A\266\202\202\n�\207" [(#("fo" 0 2 (fontified nil))) (nil) company-backend company-backends company-prefix company--manual-action functionp company-init t company-init-backend prefix company--multi-backend-adapter company--good-prefix-p company--prefix-str company-calculate-candidates message "No completion found" " " symbol-name company--update-group-lighter company-update-candidates run-hook-with-args company-completion-started-hook company-explicit-action-p company-call-frontends show throw --cl-block-nil-- company--manual-prefix company-lighter] 6 "\n\n(fn)"]()
funcall(#[0 "\n\203 �\nC\202\n��\211\205\245�\211@\300�9\204��\306�!\203<��9\2036��\307N\310=\2046��\307N?\205@�\311�!\205@��\312!\202@�\313�\312\"\240\210\300\242\203\236�\314\300\242!\203\230�\315\300\242!�\211�\301\316\f!\240\210\301\242:\204l�
\203\230�\317\320!\210\202\230�
\203t�\300\242��\2119\203\203�\321\322�!P��\202\211�\323\301\242@!\210\324\301\242!\210\325\326\327 \"\210\330\331!\210\332\333\301\242\"\210�A\266\202\202\n�\207" [(#("fo" 0 2 (fontified nil))) (nil) company-backend company-backends company-prefix company--manual-action functionp company-init t company-init-backend prefix company--multi-backend-adapter company--good-prefix-p company--prefix-str company-calculate-candidates message "No completion found" " " symbol-name company--update-group-lighter company-update-candidates run-hook-with-args company-completion-started-hook company-explicit-action-p company-call-frontends show throw --cl-block-nil-- company--manual-prefix company-lighter] 6 "\n\n(fn)"])
company--begin-new()
company--perform()
#[0 "\300 \207" [company--perform] 1 "\n\n(fn)"]()
funcall(#[0 "\300 \207" [company--perform] 1 "\n\n(fn)"])
company-auto-begin()
company-idle-begin(#<buffer *scratch*> #<window 3 on *scratch*> 5 3)
apply(company-idle-begin (#<buffer *scratch*> #<window 3 on *scratch*> 5 3))
byte-code("r\301�\302H�\303H\"\210)\301\207" [timer apply 5 6] 4)
timer-event-handler([t 21662 39799 656946 nil company-idle-begin (#<buffer *scratch*> #<window 3 on *scratch*> 5 3) nil 0])
When i decided to try this package out today, I ran into a little bit of trouble. Wasn't until I removed the filter on the server in the elisp file I understood that the problem was I didn't have pip or python-json-rpc installed.
Perhaps python-json-rpc could be pointed out as a dependency on the front page (and also the pip-behavior)?
Use python-shell-virtualenv-path
variable for python executable search. Restart anaconda_mode
if current environment different with current node instance.
There are following contib extensions planing by default in 0.2.0 version:
One little question. I'm using company-anaconda mode. And I'm getting some completions really good.
For example for:
import numpy as np
np.
After the .
I'm getting good completions. But with some other libraries I don't. I'm sure that it's because of the libraries being loaded and the default paths. How can I add more paths for this usage?
Or is it a company-anaconda question?
Define company-jedi-work-on
, company-jedi-deactivate
and company-jedi-virtualenv
commands in emacs lisp side. This commands will use /virtualenv/
resource of start_jedi
api. After activation of some virtualenv its name appears in the mode line after vc branch name. Something like Env:django-env
. Ask user to switch virtualenv automatically if current file changes on the disk. This happens mostly on switching vcs branch and many projects use different virtualenvs in different branches.
company-jedi-add-python-path
command allow user include special directories to python path throw read-dir-name
I'm using company-anaconda
, though I don't think it's related to that package. Here's the JSON-RPC error that Company gets back:
JSON-RPC error condition: :data, (:type "AttributeError\" :args ("'FakeStatement' object has no attribute 'path'") :message "'FakeStatement' object has no attribute 'path'"), :code, -32000, :message, "Server error"" with args (candidates )"))
Code smell.
Starting the HTTP server on '0.0.0.0' is a security concern for those running on a machine without a properly configured firewall. This fix changes default ip interface to 'localhost', and allow override from command line by '--ip' option.
diff --git a/company-jedi.el b/company-jedi.el
index 6620529..2014eb8 100644
--- a/company-jedi.el
+++ b/company-jedi.el
@@ -64,6 +64,7 @@
(mapconcat 'identity
(list company-jedi-python-bin "-m" "start_jedi"
"--port" (number-to-string company-jedi-port)
+ "--ip" company-jedi-host
(when company-jedi-debug "--debug"))
" ")
"Command to run start_jedi server.")
diff --git a/start_jedi/__init__.py b/start_jedi/__init__.py
index c028e80..02e1b87 100644
--- a/start_jedi/__init__.py
+++ b/start_jedi/__init__.py
@@ -2,10 +2,10 @@ import start_jedi.httpd
import start_jedi.cli
-def run(port):
+def run(port, ip='127.0.0.1'):
"""Run jedi server."""
- address = ('', port)
+ address = (ip, port)
handler = start_jedi.httpd.JediHandler
diff --git a/start_jedi/__main__.py b/start_jedi/__main__.py
index 1ae2b6c..988db8e 100644
--- a/start_jedi/__main__.py
+++ b/start_jedi/__main__.py
@@ -22,4 +22,4 @@ if args.debug:
logger.addHandler(handler)
-start_jedi.run(args.port)
+start_jedi.run(args.port, args.ip)
diff --git a/start_jedi/cli.py b/start_jedi/cli.py
index 1d8ea3b..97347a6 100644
--- a/start_jedi/cli.py
+++ b/start_jedi/cli.py
@@ -10,6 +10,8 @@ def args():
parser.add_argument('-d', '--debug', action='store_true',
help='enable debug logging')
+ parser.add_argument('-i', '--ip', type=str, default='localhost',
+ help='server IP')
parser.add_argument('-p', '--port', type=int, default=8000,
help='server port number')
If anaconda-mode-start
is called in non python mode we must ignore anaconda-mode-start-stop-hook
run.
As requested in 984050a#commitcomment-9329398, here is the traceback when I edit (triggering completion) a Python file.
Debugger entered--Lisp error: (error "Completion needs an inferior Python process running")
signal(error ("Completion needs an inferior Python process running"))
error("Completion needs an inferior Python process running")
python-completion-complete-at-point()
completion--capf-wrapper(python-completion-complete-at-point optimist)
run-hook-wrapped(completion--capf-wrapper python-completion-complete-at-point optimist)
company--capf-data-real()
company--capf-data()
company-capf(prefix)
#[0 "\n\203 \nC\202\n�\211\205\245\211@\300�9\204�\306�!\203<�9\2036�\307N\310=\2046�\307N?\205@\311�!\205@�\312!\202@\313�\312\"\240\210\300\242\203\236\314\300\242!\203\230\315\300\242!�\211�\301\316\f!\240\210\301\242:\204l
\203\230\317\320!\210\202\230
\203t\300\242��\2119\203\203\321\322�!P��\202\211\323\301\242@!\210\324\301\242!\210\325\326\327 \"\210\330\331!\210\332\333\301\242\"\210�A\266\202\202\n\207" [(nil) (nil) company-backend company-backends company-prefix company--manual-action functionp company-init t company-init-backend prefix company--multi-backend-adapter company--good-prefix-p company--prefix-str company-calculate-candidates message "No completion found" " " symbol-name company--update-group-lighter company-update-candidates run-hook-with-args company-completion-started-hook company-explicit-action-p company-call-frontends show throw --cl-block-nil-- company--manual-prefix company-lighter] 6 "\n\n(fn)"]()
funcall(#[0 "\n\203 \nC\202\n�\211\205\245\211@\300�9\204�\306�!\203<�9\2036�\307N\310=\2046�\307N?\205@\311�!\205@�\312!\202@\313�\312\"\240\210\300\242\203\236\314\300\242!\203\230\315\300\242!�\211�\301\316\f!\240\210\301\242:\204l
\203\230\317\320!\210\202\230
\203t\300\242��\2119\203\203\321\322�!P��\202\211\323\301\242@!\210\324\301\242!\210\325\326\327 \"\210\330\331!\210\332\333\301\242\"\210�A\266\202\202\n\207" [(nil) (nil) company-backend company-backends company-prefix company--manual-action functionp company-init t company-init-backend prefix company--multi-backend-adapter company--good-prefix-p company--prefix-str company-calculate-candidates message "No completion found" " " symbol-name company--update-group-lighter company-update-candidates run-hook-with-args company-completion-started-hook company-explicit-action-p company-call-frontends show throw --cl-block-nil-- company--manual-prefix company-lighter] 6 "\n\n(fn)"])
company--begin-new()
company--perform()
#[0 "\301 \210�\207" [company-candidates company--perform] 1 "\n\n(fn)"]()
funcall(#[0 "\301 \210�\207" [company-candidates company--perform] 1 "\n\n(fn)"])
company-auto-begin()
company-idle-begin(#<buffer api.py> #<window 8 on api.py> 756 814)
apply(company-idle-begin (#<buffer api.py> #<window 8 on api.py> 756 814))
byte-code("r\301�\302H�\303H\"\210)\301\207" [timer apply 5 6] 4)
timer-event-handler([t 21691 56161 440532 nil company-idle-begin (#<buffer api.py> #<window 8 on api.py> 756 814) nil 0])
Additionally, as I enter the Python file I have this message:
Compiler-macro error for python-syntax-context: (void-function python-syntax--context-compiler-macro) [2 times]
Thanks : )
Hi--
I've been playing around for an hour with anaconda-mode, but I can't seem to get it to work.
I've installed the json-rpc and jedi from pip. I didn't get a specific version like in the req file, I just used pip install jedi etc. I've installed anaconda-mode and pyenv-mode from melpa and added the following to my .emacs:
;;trying to get anaconda-mode to work
(pyenv-mode)
(add-hook 'python-mode-hook 'anaconda-mode)
I now have a json-rpc process running in the background and I can choose stuff like anaconda-mode when I press M-x. Still the various anaconda-mode options do not seem to do anything and I do not get any autocompletions.
Can you tell what I am doing wrong? Have I missed any crucial steps? Perhaps I also need the jedi.el package?
(And it might be nice for other newbs if you added some minimal steps needed to install conda mode and what you should expect to see if you have installed it correctly. Seems like a really useful package this, would be a shame if people are prevented from using due to it being slightly hard to install.)
I've downloaded and installed company-jedi
with cask
and MELPA, running Emacs 24.3 on Arch Linux. Because I already have jedi
installed for python3
, I've used (setq company-jedi-bin "python3")
before loading company-jedi
with (require 'company-jedi)
. I switch to a sample python file looking like this (| is point):
def main():
pas|
if __name__ == '__main__':
main()
I start the company-jedi-process with (company-jedi-start)
. No complaints there. htop
tells me it's running. I execute (company-jedi-candidates)
and it returns nil
. I do a counter-check by opening a python3
instance and making a sample request with the requests
module, using the output pasted from (company-jedi-request-json "candidates")
:
>>> import requests
>>> requests.post('http://localhost:24970', data="{\"command\":\"candidates\", \"attributes\":{\"source\":\"def main():\\n pas\\n\\nif __name__ == '__main__':\\n main()\\n\", \"line\":2, \"column\":7, \"point\":19, \"path\":\"\\/home\\/wasa\\/tmp\\/complete.py\", \"company_prefix\":\"\", \"company_arg\":\"\"}}").text
'["pass"]'
That proves the server is running and is able to return the correct response. I suspect something goes wrong when doing the POST
request, simply because (with-current-buffer (company-jedi-retrive (company-jedi-request-json "candidates")) (buffer-string))
returns an empty string. Could you investigate this?
Use anaconda-mode to populate imenu.
goto_definition
must ignore import lines and return only real definitions.
For provide interpreter support we must obtain local()
namespace from it. This require extra interaction with inferior process similar to slime. This is out of anaconda-mode aims.
That way, I can just use "q" instead of "C-x 1" to get rid of the doc buffer
I am using company-anaconda and anaconda from MELPA
Thanks,
Select definitions and references similar to helm-swoop.
So remote autocomplete is really cool and I plan to add it to anaconda-mode. So this is check list to implement this feature.
anaconda-mode-host
set to 'vagrant
symbol or doesn't set to loop back interfaceThe OS I used is Ubuntu 14.04, and the version of Emacs is 24.3.1.
My emacs config files is copied from https://github.com/redguardtoo/emacs.d, which using anaconda-mode for python scripts complement.
I opened first emacs program to edit python file in ubuntu terminal with emacs -nw a.py, and opened second emacs program to edit python file in another ubuntu terminal with emacs -nw b.py. The first emacs worked fine, but the second emacs has some problem. The emacs was working in vim mode, and when I press 'j' to move the cursor in the second emacs, I got some mseeage in message buffer:
Blocking call to accept-process-output with quit inhibited!!
Company back-end 'company-jedi' could not be initialized:
Symbol's function definition is void: company-jedi
then, the second emacs stuck, no response for key operations, and CPU usage was up to 100%, I had to close terminal to kill the second emacs.
Hi, thanks for this great and simple plugin.
I am developing some private modules in emacs with anaconda-mode. I want anaconda to aware of the modules I am developing.
I need to edit sys.path
to inform anaconda about this module, is there a configuration to allow me do that?
Best,
Hi,
I just want to know if there a way to avoid the "active process exist; kill then and exit anyway?" when I close Emacs and there is the running process python anaconda_mode.py
. If it's possible to configure it, do you know how I can do? If not, do you think it's possible to slightly modify the code?
I quickly tried jedi and there is no such message. I switch to anaconda because I replace auto-complete to company and jedi depends on auto-complete.
Thanks,
Damien
I'm on Emacs 24.3.50.1 and have installed the latest anaconda-mode from Melpa.
Since now anaconda use pip to install jedi, using assert to check version of jedi and jsonrpc may fail on some systems. In my case, I use mac os x, and pip1.5.6, my jedi version is "0.8.1-final10". This causes error in anaconda_mode.py.
I fixed it on my computer by modify line 37 of anaconda_mode.py:
assert jedi.__version__ == '0.8.1-final0', 'Jedi version does not match 0.8.1'
But obviously this is not a good solution.
Please fix this. Thanks.
Rebind find-tag-other-window
and find-tag-other-frame
to equivalent commands go to definition and find reference functionality. Read definition name from package module to specified method if no symbol at point available or C-u
given. This behaviour must be provided in anaconda-mode-view-doc
function too.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.