问题描述
我正在运行一个python脚本,我在笔记本电脑上训练CNN,现在想在Google云上运行它.该脚本导入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
我遵循的步骤是:
- 转到计算引擎并使用8cpus创建虚拟机
- 我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:
- wget https://www.python.org /ftp/python/3.6.3/Python-3.6.3.tgz
- tar -xvf Python-3.6.3.tgz
- cd Python-3.6.3
- ./configure
- sudo apt-get install zlib1g-dev
- sudo make
- sudo进行安装
- python3 -V
- wget https://www.python.org/ftp/python/3.6.3/Python-3.6.3.tgz
- tar -xvf Python-3.6.3.tgz
- cd Python-3.6.3
- ./configure
- sudo apt-get install zlib1g-dev
- sudo make
- sudo make install
- 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!