AttributeError:模块"tensorflow.python.training.checkpointable"没有属性"CheckpointableBase" [英] AttributeError: module 'tensorflow.python.training.checkpointable' has no attribute '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 sureimport 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:
- 通过
conda create --name tftest
创建一个新环境. (您可以将tftest
替换为当前项目的名称.) - 通过
activate tftest
激活该新环境(如果恰好使用MSYS2的bash或类似的东西,则激活source activate tftest
). - 通过
conda install tensorflow
将TF安装到此环境中. - 通过
where python
确保您处在正确的环境中(这会产生一个包含"tftest"的路径). - 通过
python
运行Python. -
import tensorflow as tf
在该环境中的外壳中.
- Create a new environment through
conda create --name tftest
. (You can replacetftest
with e.g. the name of your current project.) - Activate that new environment through
activate tftest
(orsource activate tftest
if you happen to be using MSYS2's bash, or something similar to that). - Install TF into this environment through
conda install tensorflow
. - Ensure that you're in the right environment through
where python
(which should produce a path containing "tftest"). - Run Python through
python
. 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屋!