python3.7+pycharm+tensorflow2.0+CPU下载安装配置
博主查找了大量网上资源,发现大多数都是使用anaconda下载python和tensorflow配置的,由于博主之前安装了python3.7版本,想要不通过anaconda来进行tensorflow的安装,我觉得还挺简单的。方法大致如下,版本部分大家自行调整。
1、下载安装Python3.7和pycharm,网上已有大量博文,可以参考以下内容或者自行查找。 添加链接描述
2、下载tensorflow文件,附上参考链接,添加链接描述,按照对应的python版本号,选择合适的文件进行下载,下载过程几秒钟吧。博主选择是2.0.0/py37/CPU/avx2 下载之后文件名发生了改变,要将文件名改回来,改成如下形式。 3、安装tensorflow文件。用cmd管理员方式打开python文件夹下的Scripts文件,执行如下命令:
- pip install wheel
- pip install [.whl绝对路径]
这个时候tensorflow已经下载完成了,下载也挺快的不到一分钟,可以 运行 pip show tensorflow命令查看是否安装成功。 
4、打开pycharm新建一个project,选择file/settings/python interpreter将python interpreter的路径改为之前下载的python.exe的路径。 
5、测试代码,运行一下。
import tensorflow as tf
tf.get_logger().setLevel('ERROR')
tf.compat.v1.disable_eager_execution()
y_hat = tf.constant(36, name='y_hat')
y = tf.constant(39, name='y')
loss = tf.Variable((y - y_hat) ** 2, name='loss')
init = tf.compat.v1.global_variables_initializer()
with tf.compat.v1.Session() as session:
session.run(init)
print(session.run(loss))
 至此,所有配置就完成了,还是比较快的,并没有想象中的那么麻烦。 希望大家可以从这篇文章有所收获!
|