12

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

user3177938
  • 435
  • 1
  • 5
  • 13

2 Answers2

18

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!

Bourne
  • 2,518
  • 1
  • 20
  • 27
  • 5
    I had to install a C compiler and make also: `apt install gcc make` – Gerard May 20 '19 at 15:17
  • this installation works well for python3.6 install but fails while installation of packages in pip3.6 with SSL error – BrB Dec 18 '19 at 19:21
  • 2
    @BrB You have to make sure SSL libraries are installed (```sudo apt-get install libssl-dev```) prior to compiling python3.6 (also see https://stackoverflow.com/a/54250324/1134841) – Samuel Blattner Feb 04 '20 at 08:21
-1

You can install it by using:

sudo apt-get -y -qq install python3

Check this using:

python3 --version
vine_J
  • 123
  • 6