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

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

问题描述

我一直在学习人工智能以及如何使用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:\Users\AliGalip\Anaconda3Yeni\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
    from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
  File "C:\Users\AliGalip\Anaconda3Yeni\lib\site-packages\tensorflow\python\__init__.py", line 63, in <module>
    from tensorflow.python.framework.framework_lib import *  # pylint: disable=redefined-builtin
  File "C:\Users\AliGalip\Anaconda3Yeni\lib\site-packages\tensorflow\python\framework\framework_lib.py", line 104, in <module>
    from tensorflow.python.framework.importer import import_graph_def
  File "C:\Users\AliGalip\Anaconda3Yeni\lib\site-packages\tensorflow\python\framework\importer.py", line 32, in <module>
    from tensorflow.python.framework import function
  File "C:\Users\AliGalip\Anaconda3Yeni\lib\site-packages\tensorflow\python\framework\function.py", line 36, in <module>
    from tensorflow.python.ops import resource_variable_ops
  File "C:\Users\AliGalip\Anaconda3Yeni\lib\site-packages\tensorflow\python\ops\resource_variable_ops.py", line 35, in <module>
    from tensorflow.python.ops import variables
  File "C:\Users\AliGalip\Anaconda3Yeni\lib\site-packages\tensorflow\python\ops\variables.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激活该新环境(如果恰好使用MSYS2的bash或类似的东西,则激活source activate tftest).
  3. 通过conda install tensorflow将TF安装到此环境中.
  4. 通过where python确保您处在正确的环境中(这会产生一个包含"tftest"的路径).
  5. 通过python运行Python.
  6. import tensorflow as tf在该环境中的外壳中.
  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天全站免登陆