python 安装tensorflow,及问题汇总

不废话直接干

 

第一种,装清华镜像

看别的博客

第一步你得把anaconda 给我装好

验证Anaconda是否安装成功的方法:

命令窗口中输入“conda --version”  ----->得到conda 4.2.0

看到了这个结果,恭喜你,你已经成功的安装上了Anaconda

下面神奇的时刻到了

利用windows运行控制,下面两行代码用来改成连接清华镜像的

安装Tensorflow时,需要从Anaconda仓库中下载,一般默认链接的都是国外镜像地址,下载肯定很慢啊(跨国呢!),这里我是用国内清华镜像,需要改一下链接镜像的地址。这里,我们打开刚刚安装好的Anaconda中的 Anaconda Prompt,然后输入:

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/     

conda config --set show_channel_urls yes

接下来安装Tensorflow,在Anaconda Prompt中输入:

conda create -n tensorflow python=3.6.0     (注意:自己python是哪个版本就装哪个 cmd   python --version)

一路 y 下去

结果等待安装成功

紧接着输入:activate tensorflow就Ok了(都早Anaconda Prompt 下执行)

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple/https://mirrors.tuna.tsinghua.edu.cn/tensorflow/windows/cpu/tensorflow-1.1.0-cp36-cp36m-win_amd64.whl

成功后,张量简单测试:

在Anaconda Prompt窗口中输入: python

    进入python后输入:

    import tensorflow as tf

    sess = tf.Session()

    a = tf.constant(10)

    b= tf.constant(12)

    sess.run(a+b)

结果显示正常则安装成功!

第二种:自定义安装

下面安装TensorFlow过程:
到 https://www.lfd.uci.edu/~gohlke/pythonlibs/ 下载对应的TensorFlow安装包

  • tensorflow‑1.9.0‑cp36‑cp36m‑win_amd64.whl
  • 之前下载的TensorFlow安装包放到anaconda下的Scripts文件夹下,再用pip install 进行安装
  • 这个主要是解决pip 升级冲突

总结:劳资服了csdn这群狗了

全不能用

直接 pip install tensorflow==1.4

运行cmd

库:::::::::::::::::::::::::必须一样,不然报错你都不知道哪错

期间我遇到的问题总结

使用测试tensorboard

 tensorflow ImportError: DLL load failed: 找不到指定的程序。这就是版本冲突,没别的

中间有好几种方法都是屁

误区1,没用

具体的解决方法是安装 Microsoft Visual C++ 2017 Redistributable
附上百度云安装链接:https://pan.baidu.com/s/1FoFqH01_YkG54z6XFc9HRg

误区2,狗屎

pip install protobuf==3.6.0

pip install pillow

总结先把库搞清楚再装!!!!!!!

 

  • 13
    点赞
  • 53
    收藏
    觉得还不错? 一键收藏
  • 8
    评论
在使用 TensorFlow 2.x 版本时,可能会遇到一些兼容性问题。其中一个常见的问题是 "tf.placeholder() is not compatible with eager execution." 这个错误。这是因为 TensorFlow 2.x 默认开启了 eager execution ,而 placeholder 和 eager execution 不兼容。为了解决这个问题,你可以在代码的最前面添加以下代码来禁用 eager execution : import tensorflow as tf tf.compat.v1.disable_eager_execution() 另外一个兼容性问题是关于 tf.contrib 模块的变化。在 TensorFlow 2.x 中,tf.contrib 模块已经被移除,所以你可能会遇到 "AttributeError: module 'tensorflow' has no attribute 'contrib'" 的错误。这个错误通常是由于使用了 tf.contrib.layers.l2_regularizer() 这个函数造成的。在 TensorFlow 2.x 中,你可以将它转换为 tf.keras.regularizers.l2() 。这样就可以解决这个兼容性问题。 另外,如果你需要将 TensorFlow 1.x 的代码转换为 TensorFlow 2.x 的代码,你可以使用 tf_upgrade_v2 命令行工具来完成。在命令提示符(cmd)中运行以下命令: tf_upgrade_v2 --infile file_v1.py --outfile file_v2.py 这将把名为 file_v1.py 的 TensorFlow 1.x Python 文件转换为名为 file_v2.py 的 TensorFlow 2.x 版本的文件。 通过以上的方法,你可以解决一些 TensorFlow 兼容性问题,并成功地迁移到 TensorFlow 2.x 版本。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* *3* [TensorFlow v1到v2版本兼容问题汇总与解决方案](https://blog.csdn.net/hzhaoy/article/details/104638353)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 100%"] [ .reference_list ]
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值