安装PyTorch后Conda ModuleNotFound

时间:2019-03-12 00:26:46

标签: python anaconda pytorch conda

我已经安装了Conda并可以正常工作,但是在尝试在基本环境中安装Pytorch之后,我得到了ModuleNotFoundError: No module named 'conda'

这是安装跟踪:

$ conda install pytorch torchvision -c pytorch
Collecting package metadata: done
Solving environment: done

## Package Plan ##

  environment location: /Users/yitianzou/anaconda3

  added / updated specs:
    - pytorch
    - torchvision


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    cffi-1.12.2                |   py36hb5b8e2f_1         213 KB
    ------------------------------------------------------------
                                           Total:         213 KB

The following packages will be UPDATED:

  cffi                                1.11.5-py37h6174b99_1 --> 1.12.2-py36hb5b8e2f_1
  olefile                                     0.45.1-py36_0 --> 0.46-py36_0
  pytorch                     0.4.0-py36_cuda0.0_cudnn0.0_1 --> 1.0.1-py3.6_2
  torchvision        pytorch/osx-64::torchvision-0.2.1-py3~ --> pytorch/noarch::torchvision-0.2.2-py_3

The following packages will be DOWNGRADED:

  mkl_fft                              1.0.6-py37hb8a8100_0 --> 1.0.6-py36hb8a8100_0
  mkl_random                           1.0.2-py37h27c97d8_0 --> 1.0.1-py36h5d10147_1
  numpy                               1.15.4-py37h6a91979_0 --> 1.15.4-py36h6a91979_0
  numpy-base                          1.15.4-py37h8a80b8c_0 --> 1.15.4-py36h8a80b8c_0
  pip                                         19.0.3-py37_0 --> 19.0.3-py36_0
  pycparser                                     2.19-py37_0 --> 2.19-py36_0
  python                                   3.7.2-haf84260_0 --> 3.6.8-haf84260_0
  setuptools                                  40.8.0-py37_0 --> 40.8.0-py36_0
  six                                         1.12.0-py37_0 --> 1.12.0-py36_0
  wheel                                       0.33.1-py37_0 --> 0.33.1-py36_0


Proceed ([y]/n)? y


Downloading and Extracting Packages
cffi-1.12.2          | 213 KB    | ################################### | 100% 
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
Traceback (most recent call last):
  File "/Users/yitianzou/anaconda3/bin/conda", line 12, in <module>
    from conda.cli import main
ModuleNotFoundError: No module named 'conda'

看来我的conda路径还不错:

$ which conda
/Users/yitianzou/anaconda3/condabin/conda

我的python看起来也不错:

$ python --version
Python 3.6.8 :: Anaconda custom (x86_64)

但是,每当我尝试使用conda时,我都会得到:

$ conda env list
Traceback (most recent call last):
  File "/Users/yitianzou/anaconda3/bin/conda", line 12, in <module>
    from conda.cli import main
ModuleNotFoundError: No module named 'conda'

关于如何解决此问题的任何想法?

1 个答案:

答案 0 :(得分:0)

回复晚了,但可能对面临同样问题的其他人有所帮助。我遇到了同样的事情,并通过在同一路径上使用 -u 选项通过安装程序重新安装 anaconda 来修复它。在检查 conda 列表后,我发现我错误地安装了与当前 conda 环境不兼容的 pytroch。