AttributeError: module 'tensorflow.python.training.checkpointable' has no attribute 'CheckpointableBase'

人盡茶涼 提交于 2019-12-19 09:42:20

问题


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'

回答1:


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

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?

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. 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.

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.



来源:https://stackoverflow.com/questions/51390692/attributeerror-module-tensorflow-python-training-checkpointable-has-no-attrib

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!