質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Python 3.x

Python 3はPythonプログラミング言語の最新バージョンであり、2008年12月3日にリリースされました。

PyCharm

エディター・開発ツール

Q&A

解決済

1回答

2561閲覧

tensorflowのresnetでインポートエラー

good_morning

総合スコア61

Python 3.x

Python 3はPythonプログラミング言語の最新バージョンであり、2008年12月3日にリリースされました。

PyCharm

エディター・開発ツール

0グッド

0クリップ

投稿2018/05/01 05:38

tensorflowの画像認識モデルとして評判の良いresnetをgithubからcloneして利用しようとして、まずはmnistを実行しようとしたら、次のエラーメッセージが出ました。

[error message]
from official.mnist import dataset
ImportError: No module named 'official'
Process finished with exit code 1

ソースコードには確かに次の文がはいっています。

[import statements]
import tensorflow as tf # pylint: disable=g-bad-import-order

from official.mnist import dataset
from official.utils.arg_parsers import parsers
from official.utils.logs import hooks_helper
from official.utils.misc import model_helpers

その対応策として、githubには次の記述がありました。

Running the models
The Official Models are made available as a Python module. To run the models and associated scripts, add the top-level /models folder to the Python path with the command: export PYTHONPATH="$PYTHONPATH:/path/to/models"
To install dependencies pass -r official/requirements.txt to pip. (i.e. pip3 install --user -r official/requirements.txt)
To make Official Models easier to use, we are planning to create a pip installable Official Models package. This is being tracked in #917.

しかし、環境はPycharmなので、上記コマンドの実行ができまいことと、linuxで行おうとしたらそれでもうまくいきませんでした。

このofficialというモジュールを使えるようにするには、どうしたらよろしいでしょうか。環境はつぎのとおりです。

【環境】
Windows10
Pycharm
Python3.5
tensorflow1.7.0

それでは、よろしくお願いします。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

mkgrei

2018/05/01 09:59

ついでに、Windows10のlinuxということはWSLということでしょうか?
good_morning

2018/06/29 06:55

これはlinuxではありません。ただし、Linuxでも同じ結果でした。
guest

回答1

0

ベストアンサー

To run the models and associated scripts, add the top-level /models folder to the Python path with the command: export PYTHONPATH="$PYTHONPATH:/path/to/models"

環境変数を設定してください。

https://stackoverflow.com/questions/42708389/how-to-set-environment-variables-in-pycharm

投稿2018/05/01 09:18

編集2018/05/01 09:21
mkgrei

総合スコア8560

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

good_morning

2018/05/01 20:43

回答ありがとうございます。 早速、試してみます。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問