Juypter notebook和ipython将tensorflow 1.14导入虚拟环境中安装的最新版本(tensorflow 2.2.0)

2024-06-26 00:17:23 发布

您现在位置:Python中文网/ 问答频道 /正文

我在一个名为tensorflow的虚拟环境中使用tensorflow。在那里,我使用pip install tensorflow==2.2.0安装了tensorflow 2.2.0。如果我列出环境中可用的包,它将列出tensorflow版本2.2.0

    conda list|grep tensorflow
# packages in environment at /home/user/anaconda3/envs/tensorflow:
tensorflow                2.2.0           mkl_py37h6e9ce2d_0  
tensorflow-base           2.2.0           mkl_py37hd506778_0    anaconda
tensorflow-estimator      2.2.0              pyh208ff02_0    anaconda

除此之外,我在ipython内核中注册了tensorflow,如下所示:

python -m ipykernel install --user --name tensorflow --display-name "Python 3.7 (tensorflow)"

但是,当我尝试通过ipython或juypter导入tensorflow时,如下所示

import tensorflow as tf
In [2]: print(f"Tensor Flow Version: {tf.__version__}")
   ...: 
Tensor Flow Version: 1.14.0

版本为1.14.0 python、ipython和juypter都在我的环境中

(tensorflow) user@user-XPS-13-9370:~$ which python
/home/user/anaconda3/envs/tensorflow/bin/python
(tensorflow) user@user-XPS-13-9370:~$ which ipython
/home/user/anaconda3/envs/tensorflow/bin/ipython
(tensorflow) user@user-XPS-13-9370:~$which jupyter
/home/user/anaconda3/envs/tensorflow/bin/jupyter

非常感谢您的帮助/建议。 谢谢


Tags: installname版本whichhomebin环境tensorflow