{"id":287,"hash":"c7edb536d8809df3df8bcdb79e56797833cf6352015125075cc08a0321cf0e66","pattern":"TensorFlow 2.0 - AttributeError: module &#39;tensorflow&#39; has no attribute &#39;Session&#39;","full_message":"When I am executing the command sess = tf.Session() in a TensorFlow 2.0 environment, I am getting an error message as below:\n\nTraceback (most recent call last):\nFile \"<stdin>\", line 1, in <module>\nAttributeError: module 'tensorflow' has no attribute 'Session'\n\nSystem information:\n\nOS platform and distribution: Windows 10\nPython version: 3.7.1\nTensorFlow version: 2.0.0-alpha0 (installed with pip)\n\nSteps to reproduce:\nInstallation\n\npip install --upgrade pip\npip install tensorflow==2.0.0-alpha0\npip install keras\npip install numpy==1.16.2\n\nExecution\n\nExecute command: import tensorflow as tf\nExecute command: sess = tf.Session()","ecosystem":"pypi","package_name":"tensorflow","package_version":null,"solution":"According to TF 1:1 Symbols Map, in TensorFlow 2.0, you should use tf.compat.v1.Session() instead of tf.Session().\n\nhttps://docs.google.com/spreadsheets/d/1FLFJLzg7WNP6JHODX5q8BDgptKafq_slHpnHVbJIteQ/edit#gid=0\n\nTo get TensorFlow 1.x-like behaviour in TensorFlow 2.0, one can run\n\nimport tensorflow.compat.v1 as tf\ntf.disable_v2_behavior()\n\nbut then one cannot benefit of many improvements made in TensorFlow 2.0. For more details, please refer to the migration guide.","confidence":0.95,"source":"stackoverflow","source_url":"https://stackoverflow.com/questions/55142951/tensorflow-2-0-attributeerror-module-tensorflow-has-no-attribute-session","votes":246,"created_at":"2026-04-19T04:41:46.109796+00:00","updated_at":"2026-04-19T04:51:57.731718+00:00"}