安装TensorFlow踩坑记录

    科技2022-08-16  106

    1. 安装aconda

    1.1 为什么使用conda

    在网络上简单了解之后,发现conda能够很方便的去管理python的不同版本,不同的环境,避免不同项目依赖不同而导致的相互响应

    1.2 如何安装

    这里只介绍一下windows的安装,其它系统大家可以自行探索一下。

    进入https://www.anaconda.com/products/individual看到如下界面,选择windows的对应版本下载:然后就是傻瓜式安装步骤了,不作赘述

    2. 创建conda 环境

    最好是创建一个新的环境来作为TensorFlow来使用,避免相互影响,创建步骤如下:

    conda create --name tensorFlow python=3.6

    其中,-- name后面跟的是环境的名称,python=3.6指的是python的版本,这里就可以看到aconda的好处了,可以创建很多个环境,供自己使用,很方便。 

    进入conda之后,默认的环境是bese,通过以下命令可以切换到,刚刚创建的环境:

    conda activate tensorFlow

     

    3. 安装TensorFlow

    3.1 第一次尝试安装TensorFlow,使用以下指令:

    conda install tensorflow

    然后,等待...........................

    3.2 pycharm中使用创建的环境

    4. 第一个TensorFlow小程序

    4.1 编写helloWord并执行

    from __future__ import print_function import tensorflow as tf # Simple hello world using TensorFlow # Create a Constant op # The op is added as a node to the default graph. # # The value returned by the constructor represents the output # of the Constant op. hello = tf.constant('Hello, TensorFlow!') # Start tf session sess = tf.Session() # Run the op print(sess.run(hello))

    4.2 遇到了第一个问题

    提示,tensorflow.python.tools 找不到,why??????

    通过网上查询资料,应该是自己的安装手法有问题,然后,清理所有的包,然后,重新安装

    pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --ignore-installed --upgrade tensorflow

    然后,等待安装完成后,重新执行程序

    4.3 遇到了第二个问题

    from tensorflow.python._pywrap_tensorflow_internal import * ImportError: DLL load failed: 找不到指定的模块。

    这又是什么问题?真的是....... 

    通过,谷歌了解到,需要安装:

    链接如下:https://blog.csdn.net/mayang2015/article/details/108333518


    然后:终于成功了

    5. 参考

    https://blog.csdn.net/mayang2015/article/details/108333518
    Processed: 0.008, SQL: 9