python 3 not detected upon execute buffer

Bug #893813 reported by Ricopan
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
python-mode.el
Fix Released
Medium
Andreas Roehler

Bug Description

This is similar to bug #450552.
Version: python-mode.el-6.0.3

Upon execute buffer (C-c C-c) in python interpreter:

>>> ## executing temporary file /tmp/Python4165i_k.py...
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'execfile' is not defined
>>>

M-x python3 (C-c !) starts a python 3 interpreter:

Python 3.2 (r32:88445, Mar 25 2011, 19:28:28)
[GCC 4.5.2] on linux2

M-x emacs-version
GNU Emacs 23.2.1 (i686-pc-linux-gnu, GTK+ Version 2.24.4) of 2011-04-04 on rothera, modified by Debian
 M-x py-version
Using `python-mode' version 6.0.3

M-x report-emacs-bug gives (and sent to <email address hidden>)

...
In GNU Emacs 23.2.1 (i686-pc-linux-gnu, GTK+ Version 2.24.4)
 of 2011-04-04 on rothera, modified by Debian
Windowing system distributor `The X.Org Foundation', version 11.0.11001000
configured using `configure '--build' 'i686-linux-gnu' '--build' 'i686-linux-gnu' '--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib' '--localstatedir=/var/lib' '--infodir=/usr/share/info' '--mandir=/usr/share/man' '--with-pop=yes' '--enable-locallisppath=/etc/emacs23:/etc/emacs:/usr/local/share/emacs/23.2/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/23.2/site-lisp:/usr/share/emacs/site-lisp:/usr/share/emacs/23.2/leim' '--with-x=yes' '--with-x-toolkit=gtk' '--with-toolkit-scroll-bars' 'build_alias=i686-linux-gnu' 'CFLAGS=-DDEBIAN -g -O2' 'LDFLAGS=-g' 'CPPFLAGS=''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: nil
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t

Major mode: Python

Minor modes in effect:
  tooltip-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
<help-echo> <help-echo> <down-mouse-1> <mouse-1> C-c
C-c <help-echo> M-x r e p o r t - e m a c s - b u g
<return>

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
Wrote /tmp/Python1912Z3C.py

Load-path shadows:
/usr/share/emacs/23.2/site-lisp/dictionaries-common/flyspell hides /usr/share/emacs/23.2/lisp/textmodes/flyspell
/usr/share/emacs/23.2/site-lisp/dictionaries-common/ispell hides /usr/share/emacs/23.2/lisp/textmodes/ispell

Features:
(shadow sort mail-extr message sendmail ecomplete rfc822 mml mml-sec
password-cache mm-decode mm-bodies mm-encode mailcap mail-parse rfc2231
rfc2047 rfc2045 qp ietf-drums mailabbrev nnheader gnus-util netrc
time-date mm-util mail-prsvr gmm-utils wid-edit mailheader canlock sha1
hex-util hashcash mail-utils emacsbug imenu python-mode info-look info
py-shell-complete derived easymenu edmacro kmacro cl cl-19 cc-cmds
cc-engine cc-vars cc-defs regexp-opt ansi-color compile comint ring
tooltip ediff-hook vc-hooks lisp-float-type mwheel x-win x-dnd
font-setting tool-bar dnd fontset image fringe lisp-mode register page
menu-bar rfn-eshadow timer select scroll-bar mldrag mouse jit-lock
font-lock syntax facemenu font-core frame cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese hebrew
greek romanian slovak czech european ethiopic indian cyrillic chinese
case-table epa-hook jka-cmpr-hook help simple abbrev loaddefs button
minibuffer faces cus-face files text-properties overlay md5 base64
format env code-pages mule custom widget hashtable-print-readable
backquote make-network-process dbusbind system-font-setting
font-render-setting gtk x-toolkit x multi-tty emacs)

Revision history for this message
Ricopan (ricopan) wrote :

Update:

this occurs when within a virtualenv with the default python (~/my_virtual_env/bin/python) set to a local python 3.2.

Outside of virtualenv if I switch to use python 3.2 by changing py-shell-name to python3 then error does not occur.

If py-shell-name is examined to determine python3 vs python2, would be helpful to have this noted in Install.

Changed in python-mode:
assignee: nobody → Andreas Roehler (a-roehler)
importance: Undecided → Medium
milestone: none → 6.1
Revision history for this message
Andreas Roehler (a-roehler) wrote : Re: [Bug 893813] [NEW] python 3 not detected upon execute buffer

> Using `python-mode' version 6.0.3

Current trunk should display version 6.0.4, i.e. one number ahead last
release

Could you check it out and try again?

bzr branch lp:python-mode

Assume it's exists there still BTW, just let's make sure referring to.

Thanks,

Andreas

Revision history for this message
Ricopan (ricopan) wrote :
Download full text (5.0 KiB)

Yes, also with: Using `python-mode' version 6.0.4

I don't know if this is worth spending time on. Now that I realize I can
simply link my python to python3 in my virtualenv, and have py-shell set to
python3, I can avoid the error. Thanks for your attention.

On Wed, Nov 23, 2011 at 12:29 AM, Andreas Roehler <<email address hidden>
> wrote:

> > Using `python-mode' version 6.0.3
>
> Current trunk should display version 6.0.4, i.e. one number ahead last
> release
>
> Could you check it out and try again?
>
> bzr branch lp:python-mode
>
> Assume it's exists there still BTW, just let's make sure referring to.
>
> Thanks,
>
> Andreas
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/893813
>
> Title:
> python 3 not detected upon execute buffer
>
> Status in An Emacs mode for editing Python code:
> New
>
> Bug description:
> This is similar to bug #450552.
> Version: python-mode.el-6.0.3
>
> Upon execute buffer (C-c C-c) in python interpreter:
>
> >>> ## executing temporary file /tmp/Python4165i_k.py...
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> NameError: name 'execfile' is not defined
> >>>
>
> M-x python3 (C-c !) starts a python 3 interpreter:
>
> Python 3.2 (r32:88445, Mar 25 2011, 19:28:28)
> [GCC 4.5.2] on linux2
>
> M-x emacs-version
> GNU Emacs 23.2.1 (i686-pc-linux-gnu, GTK+ Version 2.24.4) of 2011-04-04
> on rothera, modified by Debian
> M-x py-version
> Using `python-mode' version 6.0.3
>
> M-x report-emacs-bug gives (and sent to <email address hidden>)
>
> ...
> In GNU Emacs 23.2.1 (i686-pc-linux-gnu, GTK+ Version 2.24.4)
> of 2011-04-04 on rothera, modified by Debian
> Windowing system distributor `The X.Org Foundation', version 11.0.11001000
> configured using `configure '--build' 'i686-linux-gnu' '--build'
> 'i686-linux-gnu' '--prefix=/usr' '--sharedstatedir=/var/lib'
> '--libexecdir=/usr/lib' '--localstatedir=/var/lib'
> '--infodir=/usr/share/info' '--mandir=/usr/share/man' '--with-pop=yes'
> '--enable-locallisppath=/etc/emacs23:/etc/emacs:/usr/local/share/emacs/23.2/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/23.2/site-lisp:/usr/share/emacs/site-lisp:/usr/share/emacs/23.2/leim'
> '--with-x=yes' '--with-x-toolkit=gtk' '--with-toolkit-scroll-bars'
> 'build_alias=i686-linux-gnu' 'CFLAGS=-DDEBIAN -g -O2' 'LDFLAGS=-g'
> 'CPPFLAGS=''
>
> Important settings:
> value of $LC_ALL: nil
> value of $LC_COLLATE: nil
> value of $LC_CTYPE: nil
> value of $LC_MESSAGES: nil
> value of $LC_MONETARY: nil
> value of $LC_NUMERIC: nil
> value of $LC_TIME: nil
> value of $LANG: en_US.UTF-8
> value of $XMODIFIERS: nil
> locale-coding-system: utf-8-unix
> default enable-multibyte-characters: t
>
> Major mode: Python
>
> Minor modes in effect:
> tooltip-mode: t
> mouse-wheel-mode: t
> tool-bar-mode: t
> menu-bar-mode: t
> file-name-shadow-mode: t
> global-font-lock-mode: t
> font-lock-mode: t
> blink-cursor-mode: t
> auto-encryption-mode: t
> auto-compression-mode: t
> line-number-mode: t
> transient-mark-mode: t
>
> Recent inpu...

Read more...

Revision history for this message
Ricopan (ricopan) wrote :

Noted this similar issue raised at StackOverflow:

Specifying python interpreter from virtualenv in emacs.

Revision history for this message
Andreas Roehler (a-roehler) wrote : Re: [Bug 893813] Re: python 3 not detected upon execute buffer

Am 24.11.2011 20:43, schrieb Ricopan:
> Noted this similar issue raised at StackOverflow:
>
> Specifying python interpreter from virtualenv in emacs.
>

maybe the link still in your cache?

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

with -r779

    `py-shell-name' accepts a PATH/TO/EXECUTABLE

    in addition to name of an installed default Python-Shell.
    Beside customize permits installing commands like

    (defun python-XYZ-shell (&optional argprompt)
      "Start an Python-XYZ interpreter ... "
      (interactive)
      (let ((py-shell-name "PATH/TO/PYTHON-XYZ"))
        (py-shell argprompt)))

BTW being not surprised should something to be done still in this area,
please write a new report, should you encounter an inconvenience,

closing this

Andreas

Changed in python-mode:
status: New → Fix Committed
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.