赞
踩
安装好tensorflowjs后报错
因为自己之前一直是使用tf2.0,而tensorflowjs使用不了2.0,而且记得命名手动删去site-packages下的tensorflow后,安装的tensorflowjs-1.3.2的,而且显示安装是成功了的,因为tensorflowjs-1.3.2依赖的是tensorflow1.15的,但是运行上面代码出了问题,问题实际上是自己配置的pip豆瓣源,所以以前存留了tensorflow2.0的安装文件。
- C:\Users\Administrator>python
- Python 3.5.2 |Anaconda 4.1.1 (64-bit)| (default, Jul 5 2016, 11:41:13) [MSC v.1900 64 bit (AMD64)] on win32
- Type "help", "copyright", "credits" or "license" for more information.
- >>> import tensorflow
- D:\AN\lib\site-packages\numpy\core\__init__.py:29: UserWarning: loaded more than 1 DLL from .libs:
- D:\AN\lib\site-packages\numpy\.libs\libopenblas.PYQHXLVVQ7VESDPUVUADXEVJOBGHJPAY.gfortran-win_amd64.dll
- D:\AN\lib\site-packages\numpy\.libs\libopenblas.TXA6YQSD3GCQQC22GEQ54J2UDCXDXHWN.gfortran-win_amd64.dll
- stacklevel=1)
- >>> print(tensorflow.__version__)
- 2.0.0
- >>> import tensorflowjs
- Traceback (most recent call last):
- File "<stdin>", line 1, in <module>
- File "D:\AN\lib\site-packages\tensorflowjs\__init__.py", line 21, in <module>
- from tensorflowjs import converters
- File "D:\AN\lib\site-packages\tensorflowjs\converters\__init__.py", line 24, in <module>
- from tensorflowjs.converters.tf_saved_model_conversion_v2 import convert_tf_saved_model
- File "D:\AN\lib\site-packages\tensorflowjs\converters\tf_saved_model_conversion_v2.py", line 38, in <module>
- import tensorflow_hub as hub
- File "D:\AN\lib\site-packages\tensorflow_hub\__init__.py", line 53, in <module>
- from tensorflow_hub.keras_layer import KerasLayer
- File "D:\AN\lib\site-packages\tensorflow_hub\keras_layer.py", line 39, in <module>
- class KerasLayer(tf.keras.layers.Layer):
- File "C:\Users\Administrator\AppData\Roaming\Python\Python35\site-packages\tensorflow_core\python\util\module_wrapper.py", line 169, in __getattr__
- attr = getattr(self._tfmw_wrapped_module, name)
- AttributeError: module 'tensorflow' has no attribute 'keras'
我发现根本现在使用的不是1.15而是2.0的,而且连import tensorflowjs都不成功的
解决方式,是在pip安装的文件下,删了tensorflow的所有文件,重新打开即可,一般来说pip源安装好的文件在:
C:\Users\Administrator\AppData\Roaming\Python\Python35\site-packages
现在就能执行成功了
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。