AttributeError:模块“tensorflow.python.training.checkpointable"没有属性“CheckpointableBase" [英] AttributeError: module 'tensorflow.python.training.checkpointable' has no attribute 'CheckpointableBase'

查看:21
本文介绍了AttributeError:模块“tensorflow.python.training.checkpointable"没有属性“CheckpointableBase"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在学习人工智能以及如何使用 Python 进行编码.我正在做一个项目,我决定更新一些 Python 包,这些包并不是新的工作,然后发生了一些事情,我无法编译我的代码.我删除了 Anaconda3 并重新设置但没有用.我一直看到我写的这个问题作为一个主题.如果有人帮助我,我会很高兴得到一些帮助.

I've been working on learning artificial intelligence and how to code with Python.I was working on a project and I decided to update some packages of Python which were not new to work on then something happened and I can't compile my codes.I deleted Anaconda3 and set it up again but not worked. I've been seeing this problem which I wrote as a topic.If someone helps me,I would be appriciated to get some help.

>>> import tensorflow as tf
  File "C:UsersAliGalipAnaconda3Yenilibsite-packages	ensorflow\__init__.py", line 24, in <module>
    from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
  File "C:UsersAliGalipAnaconda3Yenilibsite-packages	ensorflowpython\__init__.py", line 63, in <module>
    from tensorflow.python.framework.framework_lib import *  # pylint: disable=redefined-builtin
  File "C:UsersAliGalipAnaconda3Yenilibsite-packages	ensorflowpythonframeworkframework_lib.py", line 104, in <module>
    from tensorflow.python.framework.importer import import_graph_def
  File "C:UsersAliGalipAnaconda3Yenilibsite-packages	ensorflowpythonframeworkimporter.py", line 32, in <module>
    from tensorflow.python.framework import function
  File "C:UsersAliGalipAnaconda3Yenilibsite-packages	ensorflowpythonframeworkfunction.py", line 36, in <module>
    from tensorflow.python.ops import resource_variable_ops
  File "C:UsersAliGalipAnaconda3Yenilibsite-packages	ensorflowpythonops
esource_variable_ops.py", line 35, in <module>
    from tensorflow.python.ops import variables
  File "C:UsersAliGalipAnaconda3Yenilibsite-packages	ensorflowpythonopsvariables.py", line 40, in <module>
    class Variable(checkpointable.CheckpointableBase):
AttributeError: module 'tensorflow.python.training.checkpointable' has no attribute 'CheckpointableBase'

推荐答案

同样的问题已经作为 GitHub 问题发布.特别是,@allanlavoie 建议的 解决方案 可能与此处相关好吧:

The same question has been posted as a GitHub issue. In particular, the solution suggested by @allanlavoie is likely relevant here as well:

听起来像是 TensorFlow 的半更新版本.您能否尝试完全删除 TensorFlow(例如 pip uninstall tf-nightly 或安装的任何软件包),确保 import tensorflow 失败,然后重新安装?

Sounds like a half-updated version of TensorFlow. Could you try removing TensorFlow entirely (e.g. pip uninstall tf-nightly or whichever package is installed), making sure import tensorflow fails, then reinstalling?

由于您的问题很明显您正在使用 Anaconda 来管理您的 Python 环境,如果上述方法未能解决您的问题,您可以尝试在干净的 conda 环境中安装 TensorFlow,如下所示:

Since it is apparent from your question that you're using Anaconda to manage your Python environments, if the above fails to solve your problem, you can try to install TensorFlow in a clean conda environment as follows:

  1. 通过conda create --name tftest创建新环境.(您可以将 tftest 替换为例如您当前项目的名称.)
  2. 通过activate tftest(或者source activate tftest,如果你碰巧使用MSYS2的bash,或者类似的东西)激活那个新环境.
  3. 通过conda install tensorflow将TF安装到这个环境中.
  4. 通过 where python 确保您处于正确的环境中(应该会生成一个包含tftest"的路径).
  5. 通过 python 运行 Python.
  6. import tensorflow as tf 在那个环境的 shell 中.
  1. Create a new environment through conda create --name tftest. (You can replace tftest with e.g. the name of your current project.)
  2. Activate that new environment through activate tftest (or source activate tftest if you happen to be using MSYS2's bash, or something similar to that).
  3. Install TF into this environment through conda install tensorflow.
  4. Ensure that you're in the right environment through where python (which should produce a path containing "tftest").
  5. Run Python through python.
  6. import tensorflow as tf in a shell in that environment.

由于您使用的是 PyCharm(参见此答案的注释),因此您需要设置 PyCharm 以改为使用这个新环境.确实,为每个项目使用新环境虽然占用大量磁盘空间,但对于避免这些相当依赖的数字包的依赖性问题是一种好方法.

Since you are using PyCharm (cf. the comments for this answer), you will then want to set up PyCharm for using this new environment instead. Indeed, using a new environment for every project, while disk space-intensive, is a good way of avoiding dependency issues for these rather dependency-heavy numerical packages.

这篇关于AttributeError:模块“tensorflow.python.training.checkpointable"没有属性“CheckpointableBase"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆