我(有)系统安装了 python 2.7、keras 和 tensorflow 工作正常。
今天我创建了一些新的 conda 环境,并在其中安装了几个包,包括较新的 tensorflow 版本。
我所做的所有安装都是首先激活感兴趣的环境,然后在环境中使用 conda install
和/或 pip install
(每当我之前在所述环境中执行 conda install pip 时都使用 pip)。
现在,出于某种原因,在停用所有 conda 环境并返回到我的系统“环境”(未激活 conda)后,我无法再导入 keras 或 tensorflow,两者都抱怨某个模块 "gast"
(请参阅下面是错误消息)。
这令人困惑,因为 conda 不应该接触环境之外的任何东西。我的python和模块都在conda之外。
which pip, which spyder, which python
.. 等等,都指向 /usr/bin
可能出了什么问题?我该如何修复损坏的系统模块?
我的系统通过 pip 安装了 keras 和 tensorflow。 conda 的 pip 会干扰他们吗?
pip show tensorflow-gpu
Name: tensorflow-gpu
Version: 1.14.0
Summary: TensorFlow is an open source machine learning framework for everyone.
Home-page: https://www.tensorflow.org/
Author: Google Inc.
Author-email: packages@tensorflow.org
License: Apache 2.0
Location: /home/user/.local/lib/python2.7/site-packages
Requires: grpcio, mock, keras-applications, enum34, tensorboard, wrapt, protobuf, keras-preprocessing, gast, wheel, numpy, termcolor, six, absl-py, tensorflow-estimator, google-pasta, backports.weakref, astor
pip show keras
Name: Keras
Version: 2.3.1
Summary: Deep Learning for humans
Home-page: https://github.com/keras-team/keras
Author: Francois Chollet
Author-email: francois.chollet@gmail.com
License: MIT
Location: /home/user/.local/lib/python2.7/site-packages
Requires: keras-applications, numpy, keras-preprocessing, scipy, h5py, pyyaml, six
>>> import tensorflow
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/user/.local/lib/python2.7/site-packages/tensorflow/__init__.py", line 28, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "/home/user/.local/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 73, in <module>
from tensorflow.python.ops.standard_ops import *
File "/home/user/.local/lib/python2.7/site-packages/tensorflow/python/ops/standard_ops.py", line 25, in <module>
from tensorflow.python import autograph
File "/home/user/.local/lib/python2.7/site-packages/tensorflow/python/autograph/__init__.py", line 37, in <module>
from tensorflow.python.autograph.core.converter import ConversionOptions
File "/home/user/.local/lib/python2.7/site-packages/tensorflow/python/autograph/core/converter.py", line 69, in <module>
from tensorflow.python.autograph.pyct import anno
File "/home/user/.local/lib/python2.7/site-packages/tensorflow/python/autograph/pyct/anno.py", line 27, in <module>
import gast
ImportError: No module named gast
import keras
Using TensorFlow backend.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/user/.local/lib/python2.7/site-packages/keras/__init__.py", line 3, in <module>
from . import utils
File "/home/user/.local/lib/python2.7/site-packages/keras/utils/__init__.py", line 6, in <module>
from . import conv_utils
File "/home/user/.local/lib/python2.7/site-packages/keras/utils/conv_utils.py", line 9, in <module>
from .. import backend as K
File "/home/user/.local/lib/python2.7/site-packages/keras/backend/__init__.py", line 1, in <module>
from .load_backend import epsilon
File "/home/user/.local/lib/python2.7/site-packages/keras/backend/load_backend.py", line 90, in <module>
from .tensorflow_backend import *
File "/home/user/.local/lib/python2.7/site-packages/keras/backend/tensorflow_backend.py", line 5, in <module>
import tensorflow as tf
File "/home/user/.local/lib/python2.7/site-packages/tensorflow/__init__.py", line 28, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "/home/user/.local/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 73, in <module>
from tensorflow.python.ops.standard_ops import *
File "/home/user/.local/lib/python2.7/site-packages/tensorflow/python/ops/standard_ops.py", line 25, in <module>
from tensorflow.python import autograph
File "/home/user/.local/lib/python2.7/site-packages/tensorflow/python/autograph/__init__.py", line 37, in <module>
from tensorflow.python.autograph.core.converter import ConversionOptions
File "/home/user/.local/lib/python2.7/site-packages/tensorflow/python/autograph/core/converter.py", line 69, in <module>
from tensorflow.python.autograph.pyct import anno
File "/home/user/.local/lib/python2.7/site-packages/tensorflow/python/autograph/pyct/anno.py", line 27, in <module>
import gast
ImportError: No module named gast