EzDevInfo.com

Pymacs

Emacs to Python interface

Pymacs lisp version rarities

I am running Ubuntu Natty and install Emacs and pymacs and ropemacs all from the repos. So when I add to my .emacs file the script to load ropemacs and pymacs I get the following error:

File mode specification error: (error "Pymacs Lisp version is 0.23, Python is 0.24-beta2"

I've been reading the docs and readmes but I haven't found out what is happening here. So I turn to you. Any ideas? Thanks!


Source: (StackOverflow)

How can I use meta-dot (M-.) in python with emacs?

Is there an equivalent of slime for python?

For example, if I position the cursor on foo() and do M-. (jump to definition) I would like to see the source definition of the function foo

This should work regardless of whether foo is in

1) the local project directory

2) in some ~/.virtualenvs/bar/lib/site-packages

3) in some other python-path

4) virtual env is in use (ie, it should look in my current virtualenv)

Does the pymacs/ropemacs combination do any of this?


Source: (StackOverflow)

Advertisements

Code autocompletion using ropemacs on opencv python bindings

I'm wondering if there's a get rope-code-assist working on the cv namespace of openCV

import cv2.cv as cv
cv.LoadImage

So far I get [no match]. Is there something else I need to do?

The cv2.pyd is in the PYTHONPATH and has been built from the opencv source.


Source: (StackOverflow)

Emacs hangs when using rope-goto-definition and rope-show-doc

I have installed ropemacs as part of the emacs-for-python collection of python development packages.

When I use the rope-goto-definition and rope-show-doc functions to goto/show library symbols I can more or less consistently get emacs to hang.

To enable introspection of libraries I added the following to $PROJECT_ROOT/.ropeproject/config.py:

VIRTUAL_ENV = "$HOME/.virtualenvs/$PROJECT_ROOT/"
ACTIVATE_FILE = VIRTUAL_ENV + "bin/activate_this.py"
execfile(ACTIVATE_FILE, dict(__file__=ACTIVATE_FILE))

It never seems to happen when jumping to project-local definitions, and not necessarily always when jumping to a library function. However, once I'm looking around in a library, it seems to consistently happen after one or two additional jumps. That said, I haven't really been able to identify a helpful pattern. Once emacs is hanging, the only thing I can do is to execute C-g a number of times, until emacs becomes responsive, and quickly kill the *Pymacs* buffer. If I'm too slow with doing that it freezes again. After having restarted Pymacs I have sometimes been able to jump to a symbol that previously made it freeze, but most of the time jumping to that same symbol will cause it to immediately freeze again. The python integration also seems to be slightly more unstable once I have restarted *Pymacs* once, at times hanging for no apparent reason other than me typing a few characters.

How could I proceed in debugging this?

I installed emacs-for-python from its git repository (rev. a5274). My emacs is from http://emacsformacosx.com/ and is at version 24.3.

EDIT: After having waited for more than fifteen minutes pymacs finally threw out an error. It was a permission error in $HOME/Library/Saved Application State/com.adobe.flashplayer.installmanager.savedState:

Opening [$HOME] project ... done pymacs-report-error: Python: OSError: [Errno 13] Permission denied: '$HOME/Library/Saved Application State/com

For some reason the directory was owned by root.

Now it seems like jumping to symbols always works, but often times it is very slow, as Iqbal Ansari suggests.

Investigating further I tried to compile the contents of the emacs-for-python installation directory (C-u 0 M-x byte-recompile-directory). It seems like it might have reduced the lookup time a little, but it's still incredibly slow at times.

What boggles me the most now is that the time it takes to jump to a definition is not consistent. The same jump, that sometimes finishes immediately, can, at other times, take several minutes.


Source: (StackOverflow)

Pymacs helper does not load

I'm running emacs 22.1.1 on OS X version 10.8 (mountain lion) and I have started setting up pymacs, rope, ropemacs according to the instructions provided here: http://www.saltycrane.com/blog/2010/05/my-emacs-python-environment/

After reaching the stage before auto-complete-mode, I get the following error when starting emacs:

("emacs")
Loading encoded-kb...done

Loading advice...done
Pymacs loading ropemacs...

An error has occurred while loading `/Users/my_name/.emacs':

error: Pymacs helper did not start within 30 seconds

To ensure normal operation, you should investigate and remove the
cause of the error in your initialization file.  Start Emacs with
the `--debug-init' option to view a complete error backtrace.

After starting emacs with the --debug-init option I get

Debugger entered--Lisp error: (error "Pymacs helper did not start within 30 seconds")
  signal(error ("Pymacs helper did not start within 30 seconds"))
  pymacs-report-error("Pymacs helper did not start within %d seconds" 30)
  pymacs-start-services()
  pymacs-serve-until-reply("eval" (pymacs-print-for-apply (quote "pymacs_load_helper")(quote ("ropemacs" "rop$
  pymacs-call("pymacs_load_helper" "ropemacs" "rope-")
  pymacs-load("ropemacs" "rope-")
  eval-buffer(#<buffer  *load*> nil "/Users/my_name/.emacs" nil t)  ; Reading at buffer position 566
  load-with-code-conversion("/Users/my_name/.emacs" "/Users/my_name/.emacs" t t)
  load("~/.emacs" t t)
  #[nil "^H\205\276^@   \306=\203^Q^@\307^H\310Q\202A^@ \311=\2033^@\312\307\313\314#\203#^@\315\202A^@\312\30$
  command-line()
  normal-top-level()

Any suggestions?


Source: (StackOverflow)

numpy 1.6.1 and python 2.7 along with ropemacs crash code completion

so now that I updated python from 2.7 to 2.7.2 i can no longer invoke rope-code assist in emacs.

import numpy as np
x = np.arange(0, 5, 0.1)

I have the typical rope 0.9.3, ropemode-0.1-rc2, pymacs 0.24-beta2, ropemacs 0.6

when doing M-/ or M-x rope-code-assist I get the following trace on numpy namespaces which I didn't get in python 2.7: (Same deal for sciPy; paradoxically, matplotlib still works)

pymacs-report-error: Python: Traceback (most recent call last):
  <abridged>
  File "c:\devel\Python\2.7-bin\lib\site-packages\rope\base\ast.py", line 30, in walk
    return method(node)
  File "c:\devel\Python\2.7-bin\lib\site-packages\rope\base\evaluate.py", line 166, in _Call
    if '__new__' in pyobject:
  File "c:\devel\Python\2.7-bin\lib\site-packages\rope\base\pyobjects.py", line 32, in __contains__
    return key in self.get_attributes()
  File "c:\devel\Python\2.7-bin\lib\site-packages\rope\base\utils.py", line 10, in _wrapper
    setattr(self, name, func(self, *args, **kwds))
  File "c:\devel\Python\2.7-bin\lib\site-packages\rope\base\builtins.py", line 81, in get_attributes
    result = _object_attributes(self.builtin, self)
  File "c:\devel\Python\2.7-bin\lib\site-packages\rope\base\builtins.py", line 123, in _object_attributes
    child = getattr(obj, name)
AttributeError: __abstractmethods__

Source: (StackOverflow)

Pymacs - Unable to call a method obtained with pymacs-eval

The Pymacs 0.25 manual has the following snippet in Section 3.4.2

(pymacs-exec "import re")
(setq matcher (pymacs-eval "re.compile('PATTERN').match"))
(pymacs-call matcher "PATTERN123")

In Emacs24.2 on Ubuntu 12.04 (32-bit) with Python 2.7.3, the first two statements execute fine, but the third one throws the following error:

pymacs-report-error: Python: Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/Pymacs.py", line 268, in loop
    value = eval(text)
  File "<string>", line 1
    (lambda (&rest arguments) (pymacs-apply (quote (pymacs-python . 5)) arguments))(".")

I don't know a lot of Elisp, but the lambda statement itself evaluates without any errors with C-x C-e, so I don't know what's going wrong. Also, looking at Pymacs.py, it looks like the code is trying to directly eval elisp code. Please help?


Source: (StackOverflow)

Python to drive Emacs; pymacs doesn't work

I've got a python script that loops indefinitely waiting for input, and then does something when the input happens. My problem is then making python tell emacs to do something. I just need some way to send emacs input and make emacs evaluate that input.

Here's some code to illustrate my problem...

while(1):

  on_off = query_lightswitch
  if on_off == 0:
      send_text_to_emacs("(setq 'lightswitch t)")

Ideally I'd send emacs a string that it evaluates in its elisp interpreter. I've tried pymacs, but it looks like pymacs is made to start stuff from emacs rather than python. When I try something like this in pymacs it locks up until the loop terminates. This looks like a problem I could solve with unix pipelines, if I knew enough. If anybody out there has any ideas on how to solve this problem I'd be much obliged, thanks.


Source: (StackOverflow)

Getting hello world to work in pymacs

Context: I have been using ropemacs for python and have pyemacs setup and working. I want to start programming emacs in python (I have some experience programming emacs in elisp). And I started off with hello world sample.

I have created ~/.emacs.d/hello.py with sample from the docs:

from Pymacs import lisp

def hello_world():
    lisp.insert("Hello from Python!")
hello_world.interaction = ''

I'm then trying to load hello.py in my init file:

(eval-after-load "pymacs"                             
  '(add-to-list 'pymacs-load-path "~/.emacs.d/"))
(pymacs-load "hello") ;;this line fails                            
(require 'hello)                                 

I get the following error. What am i doing wrong?

Debugger entered--Lisp error: (error "Pymacs loading hello...failed")          
  signal(error ("Pymacs loading hello...failed"))                              
  pymacs-report-error("Pymacs loading %s...failed" "hello")                    
  (cond (lisp-code (let ((result (eval lisp-code))) (message "Pymacs loading %$
  (let ((lisp-code (pymacs-call "pymacs_load_helper" module prefix))) (cond (l$
  pymacs-load("hello")                                                         
  eval((pymacs-load "hello") nil)                                              
  eval-last-sexp-1(nil)                                                        
  eval-last-sexp(nil)                                                          

Source: (StackOverflow)

How to prevent all hooks running before exit from being executed?

I'm talking specifically about Pymacs, but this would be useful to know if anything like that happens in other circumstances.

The problem: when something goes wrong in Pymacs, it will no matter what try to restart itself, and especially so when it fails to start at all. But somehow it is adding a hook to run before any file (not necessary in Python mode) should be saved or closed. So, what happens - it becomes impossible to shut down Emacs in a "nice" way - I can only terminate the process from shell, because Pymacs would enter an infinite loop: when saving a file - it would try to restart itself, fail and prevent the file from being saved - since it failed, it'll prompt to restart - no matter if I answer yes or no to restarting it, it will fail and ask again to restart itself.

M-x unload-feature doesn't help because it can't unload it (because .emacs loads it). I'm not sure at all by the way if the unload-feature can ever do anything meaningful :| I was trying to evaluate (setq kill-buffer-hook nil) but this didn't seem to help either. Perhaps there are some other hooks? Is there a way to force unload-feature to actually do something? In this situation I'd prefer save file and crash, then infinite loop and no crash, but file not saved situation.


Source: (StackOverflow)

pymacs-report-error: Python: TypeError: pymacs_load_helper() takes exactly 2 arguments (3 given)

Spent quite some time trying to install and configure Pymacs + ropemacs and friends onto my Mac OS 10.9 / Emacs 24.3 system and I am seeing the following issue when attempting to load any module (including ropemacs):

pymacs-report-error: Python: TypeError: pymacs_load_helper() takes exactly 2 arguments (3 given)

My environment:

rope==0.9.4
ropemacs==0.7
ropemode==0.2
pymacs==tip

My init.el:

(require 'pymacs)
(autoload 'pymacs-apply "pymacs")
(autoload 'pymacs-call "pymacs")
(autoload 'pymacs-eval "pymacs" nil t)
(autoload 'pymacs-exec "pymacs" nil t)
(autoload 'pymacs-load "pymacs" nil t)
(pymacs-load "ropemacs" "rope-")
(setq ropemacs-enable-autoimport t)

I'd really appreciate any help or information you can provide me so that I can use ropemacs.

Thanks in advance


Source: (StackOverflow)

Pymacs helper did not start after 30 seconds

I've seen other questions on this, but none of them were actually answered, and none of them are quite my issue.

I have a new system, emacs 23.1, Centos 6.2 (I think). I downloaded the newest pymacs and installed it. However, I'm getting:

error: Pymacs helper did not start within 30 seconds

This is with a .emacs and .bashrc that have always worked before. Also, it appears that when I run from gnome, it does find the pymacs helper (but ropemacs doesn't run), but in KDE (which is what I'm actually trying to use) It gives the pymacs helper error.

EDITING because I found this question when I had it again months later.

Now, I am getting the pymacs helper error in gnome too. I've commented out the line:

(autoload 'python-mode "python-mode" "Python editing mode" )

But that doesn't seem to help. This is with the newest pymacs.


Source: (StackOverflow)

Pymacs not starting on Emacs24 Carbon

I've followed the EnigmaCurry instructions for setting up a good python IDE in emacs. I didn't follow verbatim, since a bit has changed in emacs24 and I use customizer heavily to set options. In any case, when I was setting up flymake, I ran into a problem whereby Carbon Emacs doesn't have the same PATH as my shell, which I fixed by doing this.

I suspect something similar is happening with pymacs. Starting emacs, I get this error:

error: Pymacs helper did not start within 30 seconds

Inspecting the *Pymacs* buffer, I note:

ImportError: No module named Pymacs

My site-packages directory is in both my PATH and PYTHONPATH variables, but emacs seems to be overriding PYTHONPATH. To illustrate, if I type python -c "import sys; print sys.path" in a shell, I get:

['', '/usr/local/Cellar/python/2.7.2/ ... *snip* ]

But if I do the same in emacs through M-! python -c "import sys; print sys.path" [RET], I get:

['', '/usr/local/share/python',
     '/System/Library/Frameworks/Python.framework/Versions/2.6/ ... *snip* ]

IIUC, this means emacs is picking up the Mac factory default python framework, in addition to correctly picking up my manually created PYTHONPATH shell variable (the second list item). Yet, pymacs can't be found.

I've set python-python-command to python2.7 even though the correct python is ahead of that on the path. That is, python --version in a shell is 2.7, but in emacs it is 2.6.

I'm running the latest carbon emacs24 installed using homebrew.


Source: (StackOverflow)

Emacs to autocomplete all imported module functions

I have been using rope, ropemacs and pymacs for my autocompletion. It does pretty well, but I noticed that there is some limitation to the amount of completion it aids in. It only seems to complete the classes for the modules imported not all of the functions available.

How can I get my pymacs, ropemacs, rope to look up all of the functions of an imported module?


Source: (StackOverflow)

Pymacs Cannot Find Packages on Anaconda

I noticed Pymacs did not recognize packages that were installed through Anaconda.

Note: Just discovered a solution, I will enter it as an answer.


Source: (StackOverflow)