Emacs Python-mode. Newbie problem.

Discussion in 'Python' started by Lacrima, Jul 8, 2009.

  1. Lacrima

    Lacrima Guest

    Hello!

    I have just started using Emacs to write python scripts.
    I installed python-mode.el

    Then I just tried this code:

    print 'hello world'

    When I press C-c RET, new blank window is opened and emacs says:
    (Shell command succeeded with no output)
    So where is my 'hello world'?

    When I do C-c C-c, it prints 'hello world' successfully.
    Why in the first case I get no output?

    Thanks in advance!

    With regards, Max
    (sorry if my English isn't very proper)
     
    Lacrima, Jul 8, 2009
    #1
    1. Advertising

  2. >>>>> Lacrima <> (L) wrote:

    >L> Hello!
    >L> I have just started using Emacs to write python scripts.
    >L> I installed python-mode.el


    >L> Then I just tried this code:


    >L> print 'hello world'


    >L> When I press C-c RET, new blank window is opened and emacs says:
    >L> (Shell command succeeded with no output)
    >L> So where is my 'hello world'?


    >L> When I do C-c C-c, it prints 'hello world' successfully.
    >L> Why in the first case I get no output?


    Can you check in the buffer where you have the python code what command
    C-c RET is bound to?
    With C-h k C-c RET

    Shell command succeeded with no output suggests that is has a different
    binding than the standard one in python-mode.

    Did you happen to name your file 'test' or 'test.py?

    C-c RET does an import and 'import test' imports a standard module test.
    --
    Piet van Oostrum <>
    URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4]
    Private email:
     
    Piet van Oostrum, Jul 8, 2009
    #2
    1. Advertising

  3. Lacrima

    Lacrima Guest

    On Jul 8, 10:54 pm, Piet van Oostrum <> wrote:
    > >>>>> Lacrima <> (L) wrote:

    > >L> Hello!
    > >L> I have just started using Emacs to write python scripts.
    > >L> I installed python-mode.el
    > >L> Then I just tried this code:
    > >L> print 'hello world'
    > >L> When I press C-c RET, new blank window is opened and emacs says:
    > >L> (Shell command succeeded with no output)
    > >L> So where is my 'hello world'?
    > >L> When I do C-c C-c, it prints 'hello world' successfully.
    > >L> Why in the first case I get no output?

    >
    > Can you check in the buffer where you have the python code what command
    > C-c RET is bound to?
    > With C-h k C-c RET
    >
    > Shell command succeeded with no output suggests that is has a different
    > binding than the standard one in python-mode.
    >
    > Did you happen to name your file 'test' or 'test.py?
    >
    > C-c RET does an import and 'import test' imports a standard module test.
    > --
    > Piet van Oostrum <>
    > URL:http://pietvanoostrum.com[PGP 8DAE142BE17999C4]
    > Private email:


    Hi, Piet!

    Thanks for your reply!
    My file name is 'trains.py'.
    When I do C-h k C-c RET, it shows me help from manual: "C-c RET runs
    the command py-execute-import-or-reload
    which is an interactive Lisp function in `python-mode'..." and so
    on.

    And still when I do C-c RET, I receive "(Shell command succeeded with
    no output)"

    Any more help would be really appreciated, because I am newbie with
    Emacs.

    With regards, Max
     
    Lacrima, Jul 9, 2009
    #3
  4. >>>>> Lacrima <> (L) wrote:

    >L> Thanks for your reply!
    >L> My file name is 'trains.py'.
    >L> When I do C-h k C-c RET, it shows me help from manual: "C-c RET runs
    >L> the command py-execute-import-or-reload
    >L> which is an interactive Lisp function in `python-mode'..." and so
    >L> on.


    >L> And still when I do C-c RET, I receive "(Shell command succeeded with
    >L> no output)"


    >L> Any more help would be really appreciated, because I am newbie with
    >L> Emacs.


    I tested it and I can get this message also. It happens when you have no
    Python shell running (*Python* buffer). The python code is then executed
    by calling the python shell command and catching the output. This output
    is displayed in the *Python Output* buffer. It happens also with C-c C-c
    and it will give the same message.

    There is a difference, however between C-c C-x and C-c RET: The latter
    will import your module, and most modules are written such that
    importing them doesn't print anything. If you add something like
    print "test" and the end of file, then "test" will appear in the *Python
    Output* buffer.

    If your file has the print "hello world" statement it should display in
    the *Python Output* buffer. I checked that.

    On the other hand, if you have a python shell running you must make sure
    (e.g. with the cd command) that its working directory is the directory
    where your python file is located, otherwise the import statement will
    not find your file. Unless it is somewhere in the python path. Also the
    *Python* buffer will not automatically pop up if it is not visible, in
    contrast with the *Python Output* buffer.
    --
    Piet van Oostrum <>
    URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4]
    Private email:
     
    Piet van Oostrum, Jul 9, 2009
    #4
  5. Lacrima

    Lacrima Guest

    On Jul 9, 2:31 pm, Piet van Oostrum <> wrote:
    > >>>>> Lacrima <> (L) wrote:

    > >L> Thanks for your reply!
    > >L> My file name is 'trains.py'.
    > >L> When I do C-h k C-c RET, it shows me help from manual: "C-c RET runs
    > >L> the command py-execute-import-or-reload
    > >L>    which is an interactive Lisp function in `python-mode'..." and so
    > >L> on.
    > >L> And still when I do C-c RET, I receive "(Shell command succeeded with
    > >L> no output)"
    > >L> Any more help would be really appreciated, because I am newbie with
    > >L> Emacs.

    >
    > I tested it and I can get this message also. It happens when you have no
    > Python shell running (*Python* buffer). The python code is then executed
    > by calling the python shell command and catching the output. This output
    > is displayed in the *Python Output* buffer. It happens also with C-c C-c
    > and it will give the same message.
    >
    > There is a difference, however between C-c C-x and C-c RET: The latter
    > will import your module, and most modules are written such that
    > importing them doesn't print anything. If you add something like
    > print "test" and the end of file, then "test" will appear in the *Python
    > Output*  buffer.
    >
    > If your file has the print "hello world" statement it should display in
    > the *Python Output* buffer. I checked that.
    >
    > On the other hand, if you have a python shell running you must make sure
    > (e.g. with the cd command) that its working directory is the directory
    > where your python file is located, otherwise the import statement will
    > not find your file. Unless it is somewhere in the python path. Also the
    > *Python* buffer will not automatically pop up if it is not visible, in
    > contrast with the *Python Output* buffer.
    > --
    > Piet van Oostrum <>
    > URL:http://pietvanoostrum.com[PGP 8DAE142BE17999C4]
    > Private email:


    Thank you for really useful and detailed explanation. Now I can test
    my code using Emacs.
    But I think it works for me in a little bit different way.
    My file contains only the print 'hello world'.
    If I have no python shell running, then:
    a) C-c RET opens *Python Output* buffer without any output and with
    'Shell command succeeded with no output' message at the bottom
    b) C-c C-c opens *Python Output* with appropriate 'hello world'
    message.

    Then I run python shell with C-c ! command. And:
    a) C-c RET opens *Python* buffer and prints 'hello world' in the
    python shell
    b) C-c C-c gives the same result.

    With regards, Max
     
    Lacrima, Jul 9, 2009
    #5
  6. >>>>> Lacrima <> (L) wrote:

    >L> Thank you for really useful and detailed explanation. Now I can test
    >L> my code using Emacs.
    >L> But I think it works for me in a little bit different way.
    >L> My file contains only the print 'hello world'.
    >L> If I have no python shell running, then:
    >L> a) C-c RET opens *Python Output* buffer without any output and with
    >L> 'Shell command succeeded with no output' message at the bottom
    >L> b) C-c C-c opens *Python Output* with appropriate 'hello world'
    >L> message.


    >L> Then I run python shell with C-c ! command. And:
    >L> a) C-c RET opens *Python* buffer and prints 'hello world' in the
    >L> python shell
    >L> b) C-c C-c gives the same result.


    Which version of python-mode.el do you have? (Variable py-version)
    --
    Piet van Oostrum <>
    URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4]
    Private email:
     
    Piet van Oostrum, Jul 9, 2009
    #6
  7. Lacrima

    Lacrima Guest

    On Jul 9, 8:42 pm, Piet van Oostrum <> wrote:
    > >>>>> Lacrima <> (L) wrote:

    > >L> Thank you for really useful and detailed explanation. Now I can test
    > >L> my code usingEmacs.
    > >L> But I think it works for me in a little bit different way.
    > >L> My file contains only the print 'hello world'.
    > >L> If I have no python shell running, then:
    > >L> a) C-c RET opens *Python Output* buffer without any output and with
    > >L> 'Shell command succeeded with no output' message at the bottom
    > >L> b) C-c C-c opens *Python Output* with appropriate 'hello world'
    > >L> message.
    > >L> Then I run python shell with C-c ! command. And:
    > >L> a) C-c RET opens *Python* buffer and prints 'hello world' in the
    > >L> python shell
    > >L> b) C-c C-c gives the same result.

    >
    > Which version of python-mode.el do you have? (Variable py-version)
    > --
    > Piet van Oostrum <>
    > URL:http://pietvanoostrum.com[PGP 8DAE142BE17999C4]
    > Private email:


    py-version's value is "5.1.0"

    Also maybe the problem is because I use Emacs version 21.4.1. But I
    can't change it to 22, because I access Emacs via SSH on some shared
    hosting service.

    With regards, Max.
     
    Lacrima, Jul 9, 2009
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John J Lee
    Replies:
    3
    Views:
    550
    bruno at modulix
    Dec 1, 2005
  2. Edward Loper
    Replies:
    0
    Views:
    523
    Edward Loper
    Aug 7, 2007
  3. Jeffrey Moss

    eruby mode emacs with mmm-mode

    Jeffrey Moss, Jul 6, 2005, in forum: Ruby
    Replies:
    1
    Views:
    187
    Alan Chen
    Jul 6, 2005
  4. PerlFAQ Server
    Replies:
    1
    Views:
    221
    Marc Girod
    Jan 8, 2011
  5. PerlFAQ Server
    Replies:
    0
    Views:
    180
    PerlFAQ Server
    Apr 12, 2011
Loading...

Share This Page