b***@me.com
2018-04-19 04:24:31 UTC
I have a short convenience script that reports the versions of certain
packages in the current environment. It includes a series of code snippets
like this:
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__)
...
Typical output looks like this:
python: 3.6.5
tensorflow: 1.5.0
...
I recently created a new environment with Python 3.4 and now the code
doesn't work. On investigation `import tensorflow` does not raise an error
in this environment even though tensorflow is not installed. To prove it,
see the following console output:
(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.
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute '__version__'
PackageNotInstalledError: Package is not installed in prefix.
prefix: /Users/billtubbs/anaconda/envs/py34
package name: tensorflow
Can anyone explain this? I expect
import tensorflow
to raise an error if `Package is not installed`. If it doesn't raise an
error, I expect tensorflow to import correctly. Here it seems to have
loaded an empty module called `tensorflow`
packages in the current environment. It includes a series of code snippets
like this:
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__)
...
Typical output looks like this:
python: 3.6.5
tensorflow: 1.5.0
...
I recently created a new environment with Python 3.4 and now the code
doesn't work. On investigation `import tensorflow` does not raise an error
in this environment even though tensorflow is not installed. To prove it,
see the following console output:
(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):tensorflow.__version__
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 tensorflowPackageNotInstalledError: Package is not installed in prefix.
prefix: /Users/billtubbs/anaconda/envs/py34
package name: tensorflow
Can anyone explain this? I expect
import tensorflow
to raise an error if `Package is not installed`. If it doesn't raise an
error, I expect tensorflow to import correctly. Here it seems to have
loaded an empty module called `tensorflow`
--
You received this message because you are subscribed to the Google Groups "conda - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to conda+***@continuum.io.
To post to this group, send email to ***@continuum.io.
Visit this group at https://groups.google.com/a/continuum.io/group/conda/.
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/conda/bb2a6e6e-3d43-482f-a799-e820043ef066%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.
You received this message because you are subscribed to the Google Groups "conda - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to conda+***@continuum.io.
To post to this group, send email to ***@continuum.io.
Visit this group at https://groups.google.com/a/continuum.io/group/conda/.
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/conda/bb2a6e6e-3d43-482f-a799-e820043ef066%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.