本文介绍了谷歌云计算引擎更改为 python 3.6的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行一个 python 脚本,我在笔记本电脑上训练 CNN,现在想在谷歌云上运行它.该脚本导入 tensorflow 和 keras,为此我需要 Python 3.6

I am a running a python script where I train CNN on my laptop and now want to run it on google cloud. The script imports tensorflow and keras, for which I need Python 3.6

我遵循的步骤是:

  1. 转到计算引擎并使用 8cpus 创建虚拟机
  2. ssh 进入虚拟机,发现 python 版本是 2.7

如何将 python 版本更改为 3.6,以便我可以安装 keras,然后才能运行我的 python 脚本?

How can I change the python version to 3.6 so I can install keras, and then to be able to run my python script?

非常感谢您的帮助

推荐答案

我遇到了同样的问题.根据偏好,我进入/tmp: cd/tmp,但从那里,我在 VM 终端中遵循以下步骤:

I had the same problem. By preference, I cd'ed into /tmp: cd /tmp, but from there, I followed these steps in the VM terminal:

  1. wget https://www.python.org/ftp/python/3.6.3/Python-3.6.3.tgz
  2. tar -xvf Python-3.6.3.tgz
  3. cd Python-3.6.3
  4. ./configure
  5. sudo apt-get install zlib1g-dev
  6. sudo make
  7. sudo make install
  8. python3 -V

如果成功,最后一个应该打印出来:Python 3.6.3

If it works, the last one should print out: Python 3.6.3

如果它不起作用,那么您的环境有一些不同的东西阻止了它.这是从干净的 VM 环境开始的.但希望这对你有用!

If it doesn't work, then you have something different about your environment that is preventing it. This is starting from a clean VM environment. But hopefully this works out for you!

这篇关于谷歌云计算引擎更改为 python 3.6的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-21 08:03