关于anaconda内置python版本升级到3.8后,安装Tensorflow后,导入失败的解决方法

关于anaconda内置python版本升级到3.8后,安装Tensorflow后,导入失败的解决方法

由于Tensorflow1.0-2.0的版本都是只支持Python3.7以下的,所以之前大多是博客所写的安装Tensorflow的方法在anaconda升级到python3.8后,在Spyder中总是会出现“no module named tensorflow”的情况,但是在anaconda prompt 上可以 activate tensorflow,deactivate tensorflow。
在查阅的很多博客后,发现在2020.12发布的Tensorflow 2.4.0版本可以匹配python3.8版本。
在anaconda prompt 上查看自己的tensorflow 版本:conda list

conda list

安装新的tensorflow

如果安装了其他版本,可以用 pip uninstall tensorflow 卸载或者升级命令pip install --upgrade tensorflow==2.4.0 pip install --ignore-installed --upgrade tensorflow==2.4.0
我个人是先卸载了tensorflow再进行安装 pip install tensorflow==2.4.0

D:\software\Anaconda\envs\cnn-registration\python.exe D:\Code\Python\cnn-registration-publish\src\demo.py 2025-03-11 13:46:02.508874: I tensorflow/core/util/port.cc:153] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`. 2025-03-11 13:46:03.229100: I tensorflow/core/util/port.cc:153] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`. D:\software\Anaconda\envs\cnn-registration\Lib\site-packages\h5py\__init__.py:36: UserWarning: h5py is running against HDF5 1.14.6 when it was built against 1.14.5, this may cause problems _warn(("h5py is running against HDF5 {0} when it was built against {1}, " Traceback (most recent call last): File "D:\Code\Python\cnn-registration-publish\src\demo.py", line 2, in <module> import Registration File "D:\Code\Python\cnn-registration-publish\src\Registration.py", line 7, in <module> from VGG16 import VGG16mo File "D:\Code\Python\cnn-registration-publish\src\VGG16.py", line 11, in <module> class VGG16mo(tf.keras.Model): ^^^^^^^^^^^^^^ File "D:\software\Anaconda\envs\cnn-registration\Lib\site-packages\tensorflow\python\util\lazy_loader.py", line 210, in __getattr__ module = self._load() ^^^^^^^^^^^^ File "D:\software\Anaconda\envs\cnn-registration\Lib\site-packages\tensorflow\python\util\lazy_loader.py", line 52, in _load module = importlib.import_module(self.__name__) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\software\Anaconda\envs\cnn-registration\Lib\importlib\__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
最新发布
03-12
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值