安装Tensorflow时出现CondaVerificationError

时间:2019-11-18 16:27:30

标签: python tensorflow install conda

在我的64位Win10上安装Tensorflow时出现CondaVerificationError。

CondaVerificationError: The package for tensorflow-estimator located at C:\Users\viviennejia.zhong\AppData\Local\Continuum\anaconda3\pkgs\tensorflow-estimator-1.13.0-py37h39e3cac_0
appears to be corrupted. The path 'Lib/site-packages/tensorflow_estimator/python/estimator/canned/linear_optimizer/python/utils/__pycache__/sharded_mutable_dense_hashtable.cpython-37.pyc'
specified in the package manifest cannot be found.

ClobberError: This transaction has incompatible packages due to a shared path.
packages: conda-forge::tensorboard-1.13.1-py37_0, conda-forge::tensorflow-base-1.13.1-py37_7
path: 'scripts/tensorboard-script.py'

ClobberError: This transaction has incompatible packages due to a shared path.
packages: conda-forge::tensorboard-1.13.1-py37_0, conda-forge::tensorflow-base-1.13.1-py37_7
path: 'scripts/tensorboard.exe'

在某些帖子中,我看到conda clean --all可以提供帮助。运行此命令,我得到了

FileNotFoundError: [WinError 3] 'C:\\Users\\xxxx\\AppData\\Local\\Continuum\\anaconda3\\pkgs\\tensorflow-base-2.0.0-mkl_py37hd1d5974_0\\Lib\\site-packages\\tensorflow-2.0.0.data\\purelib\\tensorflow_core\\include\\tensorflow_core\\core\\common_runtime\\isolate_placer_inspection_required_ops_pass.h'

我是conda的新手,非常感谢您为解决此问题所提供的帮助。

1 个答案:

答案 0 :(得分:0)

即使在注释部分中也提供了解决方案(答案部分),以维护社区的利益。

通过pip安装Tensorflow已解决问题

pip install tensorflow (install latest version)

pip install tensorflow==2.0 (for older version)

除了上述方法外,还有一种推荐的方法是在Virtual Environment中创建一个Anaconda并在该Tensorflow中安装Virtual Environment,这在大多数情况下都适用案件。

使用虚拟环境具有

之类的优势
  • 我们可以在多个Tensorflow中维护Virtual Environments的多个版本,每个Virtual Environmentversion一样构成每个1.14, 1.15, 2.0, 2.1, 2.2,etc..
  • 我们可以在每个Python Versions中使用不同的2.x, 3.6, 3.7Virtual Environment
  • 如果我们想修改任何Tensorflow API的source code,我们可以在我们的虚拟环境中进行操作,而不会影响其他Virtual Environments中的功能。

针对不同的操作系统,创建新的虚拟环境并在Tensorflow中安装Anaconda的步骤如下所示:

# Create a New Virtual Environment
conda create --name TF_2_VE

# When conda asks you to proceed, type y:
proceed ([y]/n)?

# Activate the Virtual Environment. Conda Version > 4.6 
conda activate TF_2_VE

# Activating Virtual Environment, Conda Version < 4.6 and Windows OS
activate TF_2_VE

# Activating Virtual Environment, Conda Version < 4.6 and Linux and Mac OS
source activate TF_2_VE


# Install the TF Version you need
conda install tensorflow

以上命令将安装Latest Version中的Tensorflow(到目前为止为2.2)。如果要使用2.0之类的旧版本,可以用

替换上述命令的最后一步

conda install tensorflow==2.0