Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Hello World issues when using %% with ipython
#1
In [44]: %%python3 hello.py
    ...: 
UsageError: %%python3 is a cell magic, but the cell body is empty.

In [45]: %%python3 hello.py
    ...: d
    ...: 
Hello World

----------------
Above is what displayed on ipython.

It is weird I type"%%python3 hello.py" and ENTER, error message comes out.
But, if I typed something, e.g. "d" after ENTER, and then ENTER again, my "Hello World" is printed from hello.py.

Why? Thanks.

L
Quote
#2
Magic functions
Cell magics are prefixed with a double %%, and they are functions that get as an argument not only the rest of the line, but also the lines below it in a separate argument.
Quote
#3
(Dec-11-2016, 10:29 AM)Yoriz Wrote: Magic functions Cell magics are prefixed with a double %%, and they are functions that get as an argument not only the rest of the line, but also the lines below it in a separate argument.

So what command do I need to use if I have no argument?

I have tried "%%python","%%python2" and "%%pypy". None of them just works by ENTER.

Thanks,

L
Quote
#4
Why are you typing %% if you don't want to use that functionality just remove it.
Read the documentation on what things are rather then just using them blindly.
Quote
#5
(Dec-11-2016, 08:00 PM)Yoriz Wrote: Why are you typing %% if you don't want to use that functionality just remove it. Read the documentation on what things are rather then just using them blindly.

Ok. The correct command I should type is " %run hello.py".

I was misled by an online video, who uses "python hello.py" in ipython to run and it works for him.
Quote
#6
Running code without % is correct when not using interactive python.
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Help | Classes to use in real world soothsayerpg 9 507 Jul-08-2019, 07:30 PM
Last Post: nilamo
  running python hello world Avarage_Joe 8 1,455 Apr-13-2018, 04:20 PM
Last Post: Avarage_Joe
  Hello world! program, window disappears nerio 3 1,002 Mar-16-2018, 07:03 PM
Last Post: knackwurstbagel
  'Hello, World!' Problem - Urgent OmarSinno 7 1,232 Sep-07-2017, 06:22 AM
Last Post: OmarSinno
  install ipython on Mac landlord1984 6 4,034 Dec-11-2016, 05:00 AM
Last Post: landlord1984

Forum Jump:


Users browsing this thread: 1 Guest(s)