from platform import python_version
print('python: %s' % python_version())
if python_version() < '3.6':
import_exception = ImportError
else:
import_exception = ModuleNotFoundError
try:
import tensorflow
except import_exception:
print('tensorflow: not installed')
else:
print('tensorflow: %s' % tensorflow.__version__)
...
python: 3.6.5
tensorflow: 1.5.0
...
(py34) BillsMacBookPro:~ billtubbs$ python
Python 3.4.5 | packaged by conda-forge | (default, Sep 8 2016, 14:36:28)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.54)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
>>> tensorflow.__version__
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute '__version__'
>>> dir(tensorflow)
['__doc__', '__loader__', '__name__', '__package__', '__path__', '__spec__']
>>> exit()
(py34) BillsMacBookPro:~ billtubbs$ conda update tensorflow
PackageNotInstalledError: Package is not installed in prefix.
prefix: /Users/billtubbs/anaconda/envs/py34
package name: tensorflow
import tensorflow