Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

google cloud compute engine change to 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

The steps I followed were:

  1. Go to compute engine and create a virtual machine with 8cpus
  2. I ssh into the virtual machine, and I see that the python version is 2.7

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?

Many thanks for your help

like image 989
user3177938 Avatar asked Nov 13 '17 20:11

user3177938


1 Answers

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

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

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!

like image 134
Bourne Avatar answered Nov 13 '22 13:11

Bourne