按照代码,当我试图安装keras时,它告诉已经存在,下一行告诉没有模块找到keras。
代码第1行:
!pip install keras
结果:Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: keras in /usr/local/lib/python3.8/dist-packages (2.7.0)
WARNING: You are using pip version 21.3.1; however, version 22.0.4 is available.
You should consider upgrading via the '/usr/bin/python -m pip install --upgrade pip' command.
第二行代码:
np.random.seed(30)
import random as rn
rn.seed(30)
from keras import backend as K
import tensorflow as tf
tf.set_random_seed(30)
错误提示:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-2-52c6b868b0a2> in <module>
2 import random as rn
3 rn.seed(30)
----> 4 from keras import backend as K
5 import tensorflow as tf
6 tf.set_random_seed(30)
ModuleNotFoundError: No module named 'keras'
模块可能不在您的PATH
上,它决定可以访问哪些模块。要添加它,请运行:
export PATH="/usr/local/lib/python3.8/dist-packages:$PATH"
在您的终端。该命令将PATH
变量设置为keras
的安装目录,然后是:
,然后是PATH
变量的内容。