mathjax

2018年2月24日土曜日

TensorFlowをPython 3.6.4で入れてSyntaxErrorになった。

Ubuntu16.04にTensorFlowをインストールした。

手順は公式サイト
Installing TensorFlow on Ubuntu  |  TensorFlow
の説明の通り。TensorFlow with CPU support onlyで、Virtualenv installationでインストールをした。
$ sudo apt-get install python3-pip python3-dev python-virtualenv
$ virtualenv --system-site-packages -p python3 tensorflow
$ source ~/tensorflow/bin/activate
(tensorflow)$ easy_install -U pip
(tensorflow)$ pip3 install --upgrade tensorflow
トラブルも無く、すんなりとインストール完了。と思い、動作確認をしてみた。

tensorflowをインポートしただけなのに、シンタックスエラー。
(tensorflow)$ python
Python 3.6.4 (default, Feb 24 2018, 14:44:20)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
~/.pyenv/versions/3.6.4/lib/python3.6/site-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
  from ._conv import register_converters as _register_converters
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "~/tensorflow/lib/python3.6/site-packages/tensorflow/__init__.py", line 24, in <module>
    from tensorflow.python import *
  File "~/tensorflow/lib/python3.6/site-packages/tensorflow/python/__init__.py", line 82, in <module>
    from tensorflow.python.estimator import estimator_lib as estimator
  File "~/tensorflow/lib/python3.6/site-packages/tensorflow/python/estimator/estimator_lib.py", line 37, in <module>
    from tensorflow.python.estimator.inputs import inputs
  File "~/tensorflow/lib/python3.6/site-packages/tensorflow/python/estimator/inputs/inputs.py", line 22, in <module>
    from tensorflow.python.estimator.inputs.numpy_io import numpy_input_fn
  File "~/tensorflow/lib/python3.6/site-packages/tensorflow/python/estimator/inputs/numpy_io.py", line 23, in <module>
    from tensorflow.python.estimator.inputs.queues import feeding_functions
  File "~/tensorflow/lib/python3.6/site-packages/tensorflow/python/estimator/inputs/queues/feeding_functions.py", line 40, in <module>
    import pandas as pd
  File "~/.pyenv/versions/3.6.4/lib/python3.6/site-packages/pandas/__init__.py", line 23, in <module>
    from pandas.compat.numpy import *
  File "~/.pyenv/versions/3.6.4/lib/python3.6/site-packages/pandas/compat/__init__.py", line 409, in <module>
    from dateutil import parser as _date_parser
  File "~/.pyenv/versions/3.6.4/lib/python3.6/site-packages/dateutil/parser.py", line 158
    l.append("%s=%s" % (attr, `value`))
                              ^
SyntaxError: invalid syntax
>>>
どうしたものかと思ったけれど、pandasをupgradeしたところ、python-dateutilが新しくなり、問題が起きなくなった。
(tensorflow)$ pip3 install --upgrade pandas
Requirement already up-to-date: pandas in ./.pyenv/versions/3.6.4/lib/python3.6/site-packages
Requirement already up-to-date: pytz>=2011k in ./.pyenv/versions/3.6.4/lib/python3.6/site-packages (from pandas)
Requirement already up-to-date: numpy>=1.9.0 in ./tensorflow/lib/python3.6/site-packages (from pandas)
Collecting python-dateutil>=2 (from pandas)
  Using cached python_dateutil-2.6.1-py2.py3-none-any.whl
Requirement already up-to-date: six>=1.5 in ./tensorflow/lib/python3.6/site-packages (from python-dateutil>=2->pandas)
Installing collected packages: python-dateutil
  Found existing installation: python-dateutil 1.5
    Not uninstalling python-dateutil at ~/.pyenv/versions/3.6.4/lib/python3.6/site-packages, outside environment ~/tensorflow
Successfully installed python-dateutil-2.6.1
(tensorflow)$

0 件のコメント:

コメントを投稿