LoginSignup
2
0

More than 5 years have passed since last update.

Jupyter > Python3 > print() > end=でエラーが出る > Python2のprintを使っている > 対策

Last updated at Posted at 2017-12-07
動作環境
Ubuntu 16.04 LTS desktop amd64
IPython 5.5.0 -- An enhanced Interactive Python.

Jupyter NotebookでPython3のカーネルはインストール済み。

codeとエラー

Python3を選択して実装。

polarAndAzimuthCalc_171207.ipynb
import numpy as np

print('hello', end='')
error
  File "<ipython-input-1-ae4c065c97a5>", line 6
    print('hello', end='')
                      ^
SyntaxError: invalid syntax

Python2のprintになっている。

About

JupyterのAboutは以下となっている。

The server is running on this version of Python:
Python 2.7.12 (default, Nov 19 2016, 06:48:10) 
[GCC 5.4.0 20160609]

Current Kernel Information:
Python 2.7.12 (default, Nov 19 2016, 06:48:10) 
Type "copyright", "credits" or "license" for more information.

IPython 5.5.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

対策

answered Jul 22 '16 at 0:54
Jana

以下を実行したところ、Python3のprintになった。

python3 -m pip install ipykernel
python3 -m ipykernel install --user

JupyterのAboutの「Current Kernel Information:」は以下となった。

Current Kernel Information:
Python 3.5.2 (default, Sep 14 2017, 22:51:06) 
Type 'copyright', 'credits' or 'license' for more information
IPython 6.2.1 -- An enhanced Interactive Python. Type '?' for help.
2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0