Can't find library python

Bug #896898 reported by Lele Gaifax
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-mode.el
Fix Released
Medium
Andreas Roehler

Bug Description

I'm trying out current python-mode 6.0.4, taken from launchpad.

My emacs setup, loosely based on an old version of emacs-starter-kit, started to fail with the strange error I gave in the summary above. Even more strange, on a different machine, starting Emacs does not raise the error, but rather "automatically" opens a buffer loading the "python.el.gz" file coming with standard Emacs (24.0.91 from PPA, btw).

Upon further investigation, I isolated the problem to the latest version of python-mode, that does not occur with the official 6.0.3 released version.

To confirm that, I cloned the current launchpad branch in a temporary location, say "/tmp/python-mode-trunk", started Emacs with "emacs -Q" and executed the following in the *scratch* buffer:

(add-to-list 'load-path "/tmp/python-mode-trunk")
("/tmp/python-mode-trunk" "/etc/emacs-snapshot" "/etc/emacs" "/usr/local/share/emacs/24.0.91/site-lisp" "/usr/local/share/emacs/site-lisp" "/usr/share/emacs/24.0.91/site-lisp" "/usr/share/emacs/site-lisp" "/usr/share/emacs/24.0.91/lisp" "/usr/share/emacs/24.0.91/lisp/vc" "/usr/share/emacs/24.0.91/lisp/url" "/usr/share/emacs/24.0.91/lisp/textmodes" "/usr/share/emacs/24.0.91/lisp/progmodes" ...)
(load-library "python-mode")

At this point Emacs yielded the following traceback:

Debugger entered--Lisp error: (error "Can't find library python")
  signal(error ("Can't find library python"))
  error("Can't find library %s" "python")
  find-library-name("python")
  find-function-search-for-symbol(python-mode nil "python")
  find-function-noselect(python-mode)
  (car (find-function-noselect (quote python-mode)))
  (buffer-file-name (car (find-function-noselect (quote python-mode))))
  (file-name-directory (buffer-file-name (car (find-function-noselect (quote python-mode)))))
  (setq py-install-directory (file-name-directory (buffer-file-name (car (find-function-noselect (quote python-mode))))))
  (cond (py-install-directory (add-to-list (quote load-path) (expand-file-name py-install-directory)) (add-to-list (quote load-path) (concat (expand-file-name py-install-directory) "/completion")) (add-to-list (quote load-path) (concat py-install-directory "/pymacs")) (add-to-list (quote load-path) (concat (expand-file-name py-install-directory) "/test")) (add-to-list (quote load-path) (concat (expand-file-name py-install-directory) "/tools"))) (t (setq py-install-directory (file-name-directory (buffer-file-name (car (find-function-noselect (quote python-mode))))))))
  py-set-load-path()
  eval-buffer(#<buffer *load*> nil "/tmp/python-mode-trunk/python-mode.el" nil t) ; Reading at buffer position 25576
  load-with-code-conversion("/tmp/python-mode-trunk/python-mode.el" "/tmp/python-mode-trunk/python-mode.el" nil nil)
  load("python-mode")
  load-library("python-mode")
  eval((load-library "python-mode") nil)
  eval-last-sexp-1(t)
  eval-last-sexp(t)
  eval-print-last-sexp()
  call-interactively(eval-print-last-sexp nil nil)

Examining the source code, I see that the function py-set-load-path uses the variable py-install-directory... and effectively if I set the variable *before* loading the module, everything works as expected.

So, am I doing something wrong, or does the INSTALL instructions need a tweak mentioning the py-install-directory?

Thanks in advance, lele.

Changed in python-mode:
assignee: nobody → Andreas Roehler (a-roehler)
milestone: none → 6.0.4
importance: Undecided → Medium
Revision history for this message
Andreas Roehler (a-roehler) wrote :

Hi,

your rationale reads plausible. Also think seeing the reason:

(py-set-load-path) looks for a function python-mode, resp. it's buffer-file at a moment,
were it isn't defined yet.

However can't reproduce the bug.

When starting from Emacs -Q
(add-to-list 'load-path "MY_PATH_to_Python-mode.el")
and
(load-library "python-mode")

seeing

Loading python-mode...done
t

;;;;;;;;;;

Anyway, will follow your proposal,

thanks,

Andreas

Revision history for this message
Andreas Roehler (a-roehler) wrote :

error you experience might be caused due load-library being designed for interactive use.

its written:

   (list (completing-read "Load library: "
     (apply-partially 'locate-file-completion-table
                                           load-path
                                           (get-load-suffixes)))))

think apply-partially might have done some unexpected things from your environment

while python-mode developed here provides 'python-mode, load fails looking for 'python

Revision history for this message
Lele Gaifax (lelegaifax) wrote :

Hi Andreas, thank you for investigating!

Regarding you #1 comment, did you check the buffers list? As said, on a different machine I end up having a buffer "python.elc" loaded into Emacs, without errors...

Revision history for this message
Andreas Roehler (a-roehler) wrote : Re: [Bug 896898] Re: Can't find library python

Am 28.11.2011 10:20, schrieb Lele Gaifax:
> Hi Andreas, thank you for investigating!
>
> Regarding you #1 comment, did you check the buffers list?

Hi Lele,

don't see the buffers list mentioned, don't think it's related.

BTW as the error reported presumably is caused by the starter-kit stuff,
a Python Emacs Environment with python-mode.el and other python-mode is
nascending here:

https://github.com/pdee/pdee

it's still within first steps, but also relates to starter-kit

python-mode.el developed here is mirrored

https://github.com/pdee/pdee/tree/master/python-modes/python-mode-el

  As said, on a
> different machine I end up having a buffer "python.elc" loaded into
> Emacs, without errors...
>

well, that's the python-mode shipped with GNU Emacs probably.

Regards,

Andreas

Changed in python-mode:
status: New → Fix Committed
Revision history for this message
Lele Gaifax (lelegaifax) wrote :

> don't see the buffers list mentioned, don't think it's related.

I mention that case in the second paragraph of the original report:
upon loading the python-mode.el, Emacs ended up with three active
buffers, "*scratch*", "*Messages*" and "python.el"

> BTW as the error reported presumably is caused by the starter-kit
> stuff

I don't think that's possible: being paranoid, I tried with "emacs -Q"
*after* a "mv ~/.emacs.d ~/.emacs.d-out-of-the-way"...

> a Python Emacs Environment with python-mode.el and other
> python-mode is nascending here:
>
> https://github.com/pdee/pdee

Yes, thank you, I kept an eye on that. To be exact, my "loosely
esk-based startup" is actually

  https://github.com/gabrielelanaro/emacs-starter-kit

which seems in some way originated the pdee project.

Thanks again for the quick fix,
ciao, lele.

Changed in python-mode:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.