简体   繁体   中英

How to install tensorflow 1.12 in Colab?

I have been trying to run someone else's code in Colab and have been struggling with this for days now (I tried to avoid installing it's tensorflow version, but it seems to be necessary).

I obviously tried with:

!pip install tensorflow==1.12

But it says:

ERROR: Could not find a version that satisfies the requirement tensorflow==1.12 (from versions: 1.13.1, 1.13.2, 1.14.0, 1.15.0, 1.15.2, 1.15.3, 1.15.4, 1.15.5, 2.0.0, 2.0.1, 2.0.2, 2.0.3, 2.0.4, 2.1.0, 2.1.1, 2.1.2, 2.1.3, 2.1.4, 2.2.0rc0, 2.2.0rc1, 2.2.0rc2, 2.2.0rc3, 2.2.0rc4, 2.2.0, 2.2.1, 2.2.2, 2.2.3, 2.3.0rc0, 2.3.0rc1, 2.3.0rc2, 2.3.0, 2.3.1, 2.3.2, 2.3.3, 2.3.4, 2.4.0rc0, 2.4.0rc1, 2.4.0rc2, 2.4.0rc3, 2.4.0rc4, 2.4.0, 2.4.1, 2.4.2, 2.4.3, 2.4.4, 2.5.0rc0, 2.5.0rc1, 2.5.0rc2, 2.5.0rc3, 2.5.0, 2.5.1, 2.5.2, 2.6.0rc0, 2.6.0rc1, 2.6.0rc2, 2.6.0, 2.6.1, 2.6.2, 2.7.0rc0, 2.7.0rc1, 2.7.0, 2.8.0rc0)

ERROR: No matching distribution found for tensorflow==1.12

I also tried with:

!pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.12.0-cp36-cp36m-linux_x86_64.whl

And got:

ERROR: tensorflow-1.12.0-cp36-cp36m-linux_x86_64.whl is not a supported wheel on this platform.

Does anyone know which command(s) would work?

Thanks to William D. Irons for helping. This is the code that I ended up with:

from IPython.display import clear_output
import time
!add-apt-repository --yes ppa:deadsnakes/ppa
!apt-get update
!apt-get install python3.6
!apt-get install python3.6-dev

!wget https://bootstrap.pypa.io/get-pip.py && python3.6 get-pip.py
  
import sys

sys.path[2] = '/usr/lib/python36.zip'
sys.path[3] = '/usr/lib/python3.6'
sys.path[4] = '/usr/lib/python3.6/lib-dynload'
sys.path[5] = '/usr/local/lib/python3.6/dist-packages'
sys.path[7] = '/usr/local/lib/python3.6/dist-packages/IPython/extensions'

!pip install tensorflow==1.12

clear_output()
time.sleep(1)

import os
os.kill(os.getpid(), 9) #(This automatically restarts the runtime so the changes take effect)

Hope it helps someone else with the same problem

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM