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

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

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

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

Q&A

解決済

1回答

1407閲覧

import時のエラー

s_mayo

総合スコア1

Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

0グッド

0クリップ

投稿2022/10/24 03:18

前提

画像を用いた機械学習をしようと思っております。
gpuを導入してからtensorflow_hubのimport時ににエラーが出るようになりました。

実現したいこと

tensorflow_hubのimport

発生している問題・エラーメッセージ

--------------------------------------------------------------------------- ModuleNotFoundError Traceback (most recent call last) ~\AppData\Local\Temp\ipykernel_4116\551644934.py in <module> 1 import tensorflow ----> 2 import tensorflow_hub ~\anaconda3\lib\site-packages\tensorflow_hub\__init__.py in <module> 86 87 ---> 88 from tensorflow_hub.estimator import LatestModuleExporter 89 from tensorflow_hub.estimator import register_module_for_export 90 from tensorflow_hub.feature_column import image_embedding_column ~\anaconda3\lib\site-packages\tensorflow_hub\estimator.py in <module> 60 61 ---> 62 class LatestModuleExporter(tf.compat.v1.estimator.Exporter): 63 """Regularly exports registered modules into timestamped directories. 64 ~\anaconda3\lib\site-packages\tensorflow\python\util\lazy_loader.py in __getattr__(self, item) 60 61 def __getattr__(self, item): ---> 62 module = self._load() 63 return getattr(module, item) 64 ~\anaconda3\lib\site-packages\tensorflow\python\util\lazy_loader.py in _load(self) 43 """Load the module and insert it into the parent's globals.""" 44 # Import the target module and insert it into the parent's namespace ---> 45 module = importlib.import_module(self.__name__) 46 self._parent_module_globals[self._local_name] = module 47 ~\anaconda3\lib\importlib\__init__.py in import_module(name, package) 125 break 126 level += 1 --> 127 return _bootstrap._gcd_import(name[level:], package, level) 128 129 ~\anaconda3\lib\site-packages\tensorflow_estimator\python\estimator\api\_v1\estimator\__init__.py in <module> 6 import sys as _sys 7 ----> 8 from tensorflow_estimator.python.estimator.api._v1.estimator import experimental 9 from tensorflow_estimator.python.estimator.api._v1.estimator import export 10 from tensorflow_estimator.python.estimator.api._v1.estimator import inputs ~\anaconda3\lib\site-packages\tensorflow_estimator\python\estimator\api\_v1\estimator\experimental\__init__.py in <module> 6 import sys as _sys 7 ----> 8 from tensorflow_estimator.python.estimator.canned.dnn import dnn_logit_fn_builder 9 from tensorflow_estimator.python.estimator.canned.kmeans import KMeansClustering as KMeans 10 from tensorflow_estimator.python.estimator.canned.linear import LinearSDCA ~\anaconda3\lib\site-packages\tensorflow_estimator\python\estimator\canned\dnn.py in <module> 25 from tensorflow.python.framework import ops 26 from tensorflow.python.util.tf_export import estimator_export ---> 27 from tensorflow_estimator.python.estimator import estimator 28 from tensorflow_estimator.python.estimator.canned import head as head_lib 29 from tensorflow_estimator.python.estimator.canned import optimizers ~\anaconda3\lib\site-packages\tensorflow_estimator\python\estimator\estimator.py in <module> 29 from google.protobuf import message 30 from tensorflow.core.framework import summary_pb2 ---> 31 from tensorflow.python.checkpoint import checkpoint as trackable_util 32 from tensorflow.python.checkpoint import checkpoint_management 33 from tensorflow.python.checkpoint import graph_view ModuleNotFoundError: No module named 'tensorflow.python.checkpoint'

該当のソースコード

python

1import tensorflow 2import tensorflow_hub

試したこと

tensorflowのバージョン変更。
再起動。

補足情報(FW/ツールのバージョンなど)

anaconda使用。
jupyterで作業してます。

versionは以下。
tensorboard 2.10.1
tensorboard-data-server 0.6.1
tensorboard-plugin-wit 1.8.1
tensorflow 2.10.0
tensorflow-estimator 2.10.0
tensorflow-gpu 2.10.0
tensorflow-hub 0.12.0
tensorflow-io-gcs-filesystem 0.27.0

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

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

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

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

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

jbpb0

2022/10/24 04:51 編集

> ~\anaconda3\lib\site-packages\tensorflow_estimator\python\estimator\estimator.py in <module> 29 from google.protobuf import message 30 from tensorflow.core.framework import summary_pb2 ---> 31 from tensorflow.python.checkpoint import checkpoint as trackable_util 32 from tensorflow.python.checkpoint import checkpoint_management 33 from tensorflow.python.checkpoint import graph_view > ModuleNotFoundError: No module named 'tensorflow.python.checkpoint' from tensorflow.python.checkpoint import checkpoint as trackable_util は、実行できますか? もし、上記を実行した場合も質問と同じ > ModuleNotFoundError: No module named 'tensorflow.python.checkpoint' というエラーが出る場合は、 ~\anaconda3\lib\site-packages\tensorflow\python に「checkpoint」という名前のディレクトリが有るか、確認してください
jbpb0

2022/10/24 04:48

> tensorflow 2.10.0 > tensorflow-gpu 2.10.0 質問のエラーと関係有るかどうかは分かりませんが、tensorflowとtensorflow-gpuはどちらかだけインストールするものなので、両方インストールするのはやめた方がいいと思います また、tensorflow 2.*の場合は、tensorflowとtensorflow-gpuは同じものなので、どちらをインストールしてもgpuを使うことができるはずです
guest

回答1

0

自己解決

jbpb0様、コメントありがとうございます。

tensorflow-gpuのアンインストールをしようとしたところ、アンインストールがうまくできず、何やらごちゃごちゃやっていたら、tensorflow_hubのimportはできるようになりました。
はっきりと原因はわかりませんが、tensorflowとtensorflow-gpuが両方入っていたのが悪かったのかなと考えております。

アンインストールはまだうまく出来ていないのですが、表題の問題は解決いたしました。
回答ではなくコメントでの意見で、ベストアンサーにはできなかったため、自己解決とさせていただきましたが、本当に助かりました。ありがとうございました。

投稿2022/10/24 07:24

s_mayo

総合スコア1

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

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

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問