如何对Anaconda软件包管理器中的ModuleNotFoundError进行故障排除

时间:2019-05-25 21:03:03

标签: python anaconda importerror

我执行了我认为是简单的软件包安装的操作,但没有成功。接下来,我该怎么办才能解决此问题?

我做了什么(请参见下面的详细信息):

conda install yaml

接下来我要做什么:

python
Python 3.6.8 |Anaconda, Inc.| (default, Dec 30 2018, 01:22:34) 
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import yaml

我得到了什么

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'yaml'

详细信息:

(tf-cpu) [....]$ conda install yaml
Collecting package metadata: done
Solving environment: done

## Package Plan ##

  environment location: /home/billtubbs/miniconda3/envs/tf-cpu

  added / updated specs:
    - yaml


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    certifi-2019.3.9           |           py36_0         155 KB
    ------------------------------------------------------------
                                           Total:         155 KB

The following packages will be SUPERSEDED by a higher-priority channel:

  ca-certificates    conda-forge::ca-certificates-2019.3.9~ --> pkgs/main::ca-certificates-2019.1.23-0
  certifi                                       conda-forge --> pkgs/main
  openssl            conda-forge::openssl-1.1.1b-h14c3975_1 --> pkgs/main::openssl-1.1.1b-h7b6447c_1


Proceed ([y]/n)? y


Downloading and Extracting Packages
certifi-2019.3.9     | 155 KB    | ##################################### | 100% 
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
(tf-cpu) [....]$ ipython
Python 3.6.8 |Anaconda, Inc.| (default, Dec 30 2018, 01:22:34) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.5.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import yaml                                                             
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-1-38c9922a026e> in <module>
----> 1 import yaml

ModuleNotFoundError: No module named 'yaml'

In [2]: exit()                                                                  
(tf-cpu) [....]$ conda install yaml
Collecting package metadata: done
Solving environment: done

# All requested packages already installed.

(tf-cpu) [....]$ conda info --envs
# conda environments:
#
base                     /home/billtubbs/miniconda3
tf-cpu                *  /home/billtubbs/miniconda3/envs/tf-cpu
tf-gpu                   /home/billtubbs/miniconda3/envs/tf-gpu

(tf-cpu) [....]$ conda search yaml
Loading channels: done
# Name                       Version           Build  Channel             
yaml                           0.1.4               0  pkgs/free           
yaml                           0.1.6               0  pkgs/free           
yaml                           0.1.7      h014fa73_1  pkgs/main           
yaml                           0.1.7      h014fa73_2  pkgs/main           
yaml                           0.1.7      h96e3832_1  pkgs/main           
yaml                           0.1.7      had09818_2  pkgs/main           
(tf-cpu) [....]$ conda list
# packages in environment at /home/billtubbs/miniconda3/envs/tf-cpu:
#
# Name                    Version                   Build  Channel
_tflow_select             2.3.0                       mkl  
absl-py                   0.7.1                    py36_0  
astor                     0.7.1                    py36_0  
atari-py                  0.1.15                   pypi_0    pypi
backcall                  0.1.0                    py36_0  
blas                      1.0                         mkl  
c-ares                    1.15.0               h7b6447c_1  
ca-certificates           2019.1.23                     0  
certifi                   2019.3.9                 py36_0  
click                     7.0                      pypi_0    pypi
cloudpickle               1.1.1                    pypi_0    pypi
control                   0.8.2                    py36_0    conda-forge
cycler                    0.10.0                   py36_0  
dbus                      1.13.6               h746ee38_0  
decorator                 4.4.0                    py36_1  
dill                      0.2.9                    pypi_0    pypi
expat                     2.2.6                he6710b0_0  
fontconfig                2.13.0               h9420a91_0  
freetype                  2.9.1                h8a8886c_1  
future                    0.17.1                   pypi_0    pypi
gast                      0.2.2                    py36_0  
glib                      2.56.2               hd408876_0  
glob2                     0.6                      pypi_0    pypi
grpcio                    1.16.1           py36hf8bcb03_1  
gst-plugins-base          1.14.0               hbbd80ab_1  
gstreamer                 1.14.0               hb453b48_1  
gym                       0.12.4                   pypi_0    pypi
h5py                      2.9.0            py36h7918eee_0  
hdf5                      1.10.4               hb1b8bf9_0  
icu                       58.2                 h9c2bf20_1  
intel-openmp              2019.3                      199  
ipython                   7.5.0            py36h39e3cac_0  
ipython_genutils          0.2.0                    py36_0  
jedi                      0.13.3                   py36_0  
joblib                    0.13.2                   pypi_0    pypi
jpeg                      9b                   h024ee3a_2  
keras-applications        1.0.7                      py_0  
keras-preprocessing       1.0.9                      py_0  
kiwisolver                1.1.0            py36he6710b0_0  
libedit                   3.1.20181209         hc058e9b_0  
libffi                    3.2.1                hd88cf55_4  
libgcc-ng                 8.2.0                hdf63c60_1  
libgfortran-ng            7.3.0                hdf63c60_0  
libpng                    1.6.37               hbc83047_0  
libprotobuf               3.7.1                hd408876_0  
libstdcxx-ng              8.2.0                hdf63c60_1  
libuuid                   1.0.3                h1bed415_2  
libxcb                    1.13                 h1bed415_1  
libxml2                   2.9.9                he19cac6_0  
markdown                  3.1                      py36_0  
matplotlib                3.0.3            py36h5429711_0  
mkl                       2019.3                      199  
mkl_fft                   1.0.12           py36ha843d7b_0  
mkl_random                1.0.2            py36hd81dba3_0  
mock                      2.0.0                    py36_0  
mpi                       1.0                     openmpi    conda-forge
mpi4py                    2.0.0                    py36_2  
mpich2                    1.4.1p1                       0  
ncurses                   6.1                  he6710b0_1  
numpy                     1.16.3           py36h7e9f1db_0  
numpy-base                1.16.3           py36hde5b4d6_0  
openblas                  0.3.3             h9ac9557_1001    conda-forge
opencv-python             4.1.0.25                 pypi_0    pypi
openmpi                   4.0.1                hc99cbb1_0    conda-forge
openssl                   1.1.1b               h7b6447c_1  
pandas                    0.24.2           py36he6710b0_0  
parso                     0.4.0                      py_0  
pbr                       5.1.3                      py_0  
pcre                      8.43                 he6710b0_0  
pexpect                   4.7.0                    py36_0  
pickleshare               0.7.5                    py36_0  
pillow                    6.0.0                    pypi_0    pypi
pip                       19.1.1                   py36_0  
prompt_toolkit            2.0.9                    py36_0  
protobuf                  3.7.1            py36he6710b0_0  
ptyprocess                0.6.0                    py36_0  
pyglet                    1.3.2                    pypi_0    pypi
pygments                  2.4.0                      py_0  
pyparsing                 2.4.0                      py_0  
pyqt                      5.9.2            py36h05f1152_2  
python                    3.6.8                h0371630_0  
python-dateutil           2.8.0                    py36_0  
pytz                      2019.1                     py_0  
pyzmq                     18.0.1                   pypi_0    pypi
qt                        5.9.7                h5867ecd_1  
readline                  7.0                  h7b6447c_5  
scipy                     1.2.1            py36h7c811a0_0  
seaborn                   0.9.0                    pypi_0    pypi
setuptools                41.0.1                   py36_0  
sip                       4.19.8           py36hf484d3e_0  
six                       1.12.0                   py36_0  
slycot                    0.3.4.0          py36hf0b9930_0    conda-forge
sqlite                    3.28.0               h7b6447c_0  
stable-baselines          2.5.1                    pypi_0    pypi
tensorboard               1.13.1           py36hf484d3e_0  
tensorflow                1.13.1          mkl_py36h27d456a_0  
tensorflow-base           1.13.1          mkl_py36h7ce6ba3_0  
tensorflow-estimator      1.13.0                     py_0  
termcolor                 1.1.0                    py36_1  
tk                        8.6.8                hbc83047_0  
tornado                   6.0.2            py36h7b6447c_0  
tqdm                      4.32.1                   pypi_0    pypi
traitlets                 4.3.2                    py36_0  
wcwidth                   0.1.7                    py36_0  
werkzeug                  0.15.2                     py_0  
wheel                     0.33.4                   py36_0  
xz                        5.2.4                h14c3975_4  
yaml                      0.1.7                had09818_2  
zlib                      1.2.11               h7b6447c_3  
zmq                       0.0.0                    pypi_0    pypi
(tf-cpu) [....]$

1 个答案:

答案 0 :(得分:0)

这是答案:

conda install pyyaml

pip install pyyaml

有关更多信息,请参见this anaconda issue线程。

另外,this stackoverflow question相似/重复。