

tensorflowのバージョンを1.15.2に変更したいのですが、現在Google
Colab上でPythonのバージョンがデフォルトで3.8になっており、tensorflowの1.x系をインストールするには3.7にダウングレードする必要があるため、以下のサイトを参考にPythonを3.7に変更しました。

[Google
ColabでPythonのバージョンを変更（Miniconda経由）](https://krhb.hatenablog.com/entry/2021/07/04/Google_Colab%E3%81%A7Python%E3%81%AE%E3%83%90%E3%83%BC%E3%82%B8%E3%83%A7%E3%83%B3%E3%82%92%E5%A4%89%E6%9B%B4%EF%BC%88Miniconda%E7%B5%8C%E7%94%B1%EF%BC%89)

その後、以下のようにtensorflowをインストールしてバージョンを確認しようとしたのですがなぜかtensorflowが読み込まれず困っており、どうしたらよろしいでしょうか。

解決方法がございましたら、回答いただけますと幸いです。  
よろしくお願いいたします。

[code]

    !pip uninstall -y tensorflow
    !pip install tensorflow==1.15.2
    
    import tensorflow as tf
    tf.__version__
    
[/code]

出力

[code]

    Found existing installation: tensorflow 1.15.2
    Uninstalling tensorflow-1.15.2:
      Successfully uninstalled tensorflow-1.15.2
    WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
    Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/
    Collecting tensorflow==1.15.2
      Using cached tensorflow-1.15.2-cp37-cp37m-manylinux2010_x86_64.whl (110.5 MB)
    Requirement already satisfied: termcolor>=1.1.0 in /usr/local/lib/python3.7/site-packages (from tensorflow==1.15.2) (2.1.1)
    Requirement already satisfied: protobuf>=3.6.1 in /usr/local/lib/python3.7/site-packages (from tensorflow==1.15.2) (4.21.10)
    Requirement already satisfied: keras-preprocessing>=1.0.5 in /usr/local/lib/python3.7/site-packages (from tensorflow==1.15.2) (1.1.2)
    Requirement already satisfied: absl-py>=0.7.0 in /usr/local/lib/python3.7/site-packages (from tensorflow==1.15.2) (1.3.0)
    Requirement already satisfied: gast==0.2.2 in /usr/local/lib/python3.7/site-packages (from tensorflow==1.15.2) (0.2.2)
    Requirement already satisfied: six>=1.10.0 in /usr/local/lib/python3.7/site-packages (from tensorflow==1.15.2) (1.16.0)
    Requirement already satisfied: wrapt>=1.11.1 in /usr/local/lib/python3.7/site-packages (from tensorflow==1.15.2) (1.14.1)
    Requirement already satisfied: google-pasta>=0.1.6 in /usr/local/lib/python3.7/site-packages (from tensorflow==1.15.2) (0.2.0)
    Requirement already satisfied: keras-applications>=1.0.8 in /usr/local/lib/python3.7/site-packages (from tensorflow==1.15.2) (1.0.8)
    Requirement already satisfied: tensorboard<1.16.0,>=1.15.0 in /usr/local/lib/python3.7/site-packages (from tensorflow==1.15.2) (1.15.0)
    Requirement already satisfied: opt-einsum>=2.3.2 in /usr/local/lib/python3.7/site-packages (from tensorflow==1.15.2) (3.3.0)
    Requirement already satisfied: grpcio>=1.8.6 in /usr/local/lib/python3.7/site-packages (from tensorflow==1.15.2) (1.51.1)
    Requirement already satisfied: numpy<2.0,>=1.16.0 in /usr/local/lib/python3.7/site-packages (from tensorflow==1.15.2) (1.21.6)
    Requirement already satisfied: wheel>=0.26 in /usr/local/lib/python3.7/site-packages (from tensorflow==1.15.2) (0.37.1)
    Requirement already satisfied: astor>=0.6.0 in /usr/local/lib/python3.7/site-packages (from tensorflow==1.15.2) (0.8.1)
    Requirement already satisfied: tensorflow-estimator==1.15.1 in /usr/local/lib/python3.7/site-packages (from tensorflow==1.15.2) (1.15.1)
    Requirement already satisfied: h5py in /usr/local/lib/python3.7/site-packages (from keras-applications>=1.0.8->tensorflow==1.15.2) (3.7.0)
    Requirement already satisfied: markdown>=2.6.8 in /usr/local/lib/python3.7/site-packages (from tensorboard<1.16.0,>=1.15.0->tensorflow==1.15.2) (3.4.1)
    Requirement already satisfied: setuptools>=41.0.0 in /usr/local/lib/python3.7/site-packages (from tensorboard<1.16.0,>=1.15.0->tensorflow==1.15.2) (65.5.0)
    Requirement already satisfied: werkzeug>=0.11.15 in /usr/local/lib/python3.7/site-packages (from tensorboard<1.16.0,>=1.15.0->tensorflow==1.15.2) (2.2.2)
    Requirement already satisfied: importlib-metadata>=4.4 in /usr/local/lib/python3.7/site-packages (from markdown>=2.6.8->tensorboard<1.16.0,>=1.15.0->tensorflow==1.15.2) (4.11.3)
    Requirement already satisfied: MarkupSafe>=2.1.1 in /usr/local/lib/python3.7/site-packages (from werkzeug>=0.11.15->tensorboard<1.16.0,>=1.15.0->tensorflow==1.15.2) (2.1.1)
    Requirement already satisfied: zipp>=0.5 in /usr/local/lib/python3.7/site-packages (from importlib-metadata>=4.4->markdown>=2.6.8->tensorboard<1.16.0,>=1.15.0->tensorflow==1.15.2) (3.8.0)
    Requirement already satisfied: typing-extensions>=3.6.4 in /usr/local/lib/python3.7/site-packages (from importlib-metadata>=4.4->markdown>=2.6.8->tensorboard<1.16.0,>=1.15.0->tensorflow==1.15.2) (4.4.0)
    Installing collected packages: tensorflow
    Successfully installed tensorflow-1.15.2
    WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
    ---------------------------------------------------------------------------
    ModuleNotFoundError                       Traceback (most recent call last)
    <ipython-input-9-fa12b07dae70> in <module>
          2 get_ipython().system('pip install tensorflow==1.15.2')
          3 
    ----> 4 import tensorflow as tf
          5 tf.__version__
    
    ModuleNotFoundError: No module named 'tensorflow'
    
    ---------------------------------------------------------------------------
    NOTE: If your import is failing due to a missing package, you can
    manually install dependencies using either !pip or !apt.
    
    To view examples of installing some common dependencies, click the
    "Open Examples" button below.
    ---------------------------------------------------------------------------
    
[/code]


CC BY-SA 4.0
2022-12-03T09:38:30.177
92553
2023-01-14T15:06:35.837
2022-12-03T09:54:59.503
3060
55747
question
python tensorflow google-colaboratory
Google Colab上でtensorflowのバージョンを変更したい


[Google Colab
でバージョン指定したインストールができない](https://ja.stackoverflow.com/questions/92537)
にて回答していますが、Google
Colaboratoryにてtensorflow1系のサポートは終了したようです。他の環境での1系の使用を検討されるか、2系への移行を検討されるのが良いかと思います。


CC BY-SA 4.0
2022-12-03T10:29:11.717
92554
2022-12-03T10:29:11.717
39819
92553
answer