无法从’tensorflow.python.framework’中导入’name’类型规范。

huangapple go评论57阅读模式
英文:

cannot import name 'type_spec_registry' from 'tensorflow.python.framework'

问题

我正在进行我的硕士项目,使用MARL,并决定使用RLLib。我为我的项目创建了一个conda环境,并安装了RLLib:

pip install "ray[rllib]" tensorflow

随后,我尝试运行一个实验:

rllib train --algo DQN --env CartPole-v1

但出现了以下错误:“ImportError: 无法从'tensorflow.python.framework'导入名称'type_spec_registry'。”

我正在使用Tensorflow 2.11。

提前感谢!我试图运行一个RLLib库的实验,以测试库是否正确安装。

英文:

I am working on my Master's project with MARL, and i decided to use RLLib. I created a conda environment for my project and installed RLLib:

pip install "ray[rllib]" tensorflow

Later on, i tried to run one experiment:

rllib train --algo DQN --env CartPole-v1

But got the following error: "ImportError: cannot import name 'type_spec_registry' from 'tensorflow.python.framework'"

I am using Tensorflow 2.11.

Thanks in advance!

I was trying to run one experiment from RLLib library in order to test if the library is correctly installed.

答案1

得分: 4

我在安装tf-nightly后,然后回滚到tensorflow v2.11.0后遇到了相同的问题。

我不确定根本原因,但将tensorflow降级到版本2.10.1可以解决这个问题。之后,我可以升级回2.11.0而不会出现导入异常。

# 降级
pip install tensorflow==2.10.1
# 在这一点上tensorflow可以正常工作

# 然后升级到最新版本也可以正常工作
pip install -U tensorflow
英文:

I had the same issue after installing tf-nightly then reverting back to tensorflow v2.11.0.

I'm unsure of root cause, but downgrading tensorflow to version 2.10.1 fixed it on my machine. After this I was able to upgrade back to 2.11.0 without the import exception.

# downgrade
pip install tensorflow==2.10.1
# tensorflow was working at this point

# then upgrading to the latest worked as well
pip install -U tensorflow

huangapple
  • 本文由 发表于 2023年2月6日 16:58:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/75359182.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定