更新了Anaconda,导入scipy时出现错误消息“无法导入名称'moduleTNC'”

时间:2015-06-23 19:51:53

标签: python ipython-notebook anaconda

我使用conda update anaconda在Windows上更新了anaconda。现在我的ipython笔记本,以

开头
import numpy as np
from numpy.random import randn
import pandas as pd
from scipy import stats
import matplotlib as mpl
import matplotlib.pyplot as plt
import seaborn as sns
...

给了我错误:

ImportError                               Traceback (most recent call last)
<ipython-input-1-2bb1109a8767> in <module>()
      2 from numpy.random import randn
      3 import pandas as pd
----> 4 from scipy import stats
      5 import matplotlib as mpl
      6 import matplotlib.pyplot as plt

C:\Users\Me\Anaconda\lib\site-packages\scipy\stats\__init__.py in <module>()
    336 from __future__ import division, print_function, absolute_import
    337 
--> 338 from .stats import *
    339 from .distributions import *
    340 from .rv import *

C:\Users\Me\Anaconda\lib\site-packages\scipy\stats\stats.py in <module>()
    187 
    188 from . import futil
--> 189 from . import distributions
    190 
    191 from ._rank import rankdata, tiecorrect

C:\Users\Me\Anaconda\lib\site-packages\scipy\stats\distributions.py in <module>()
      8 from __future__ import division, print_function, absolute_import
      9 
---> 10 from ._distn_infrastructure import (entropy, rv_discrete, rv_continuous,
     11                                     rv_frozen)
     12 

C:\Users\Me\Anaconda\lib\site-packages\scipy\stats\_distn_infrastructure.py in <module>()
     21 
     22 # for root finding for discrete distribution ppf, and max likelihood estimation
---> 23 from scipy import optimize
     24 
     25 # for functions of continuous distributions (e.g. moments, entropy, cdf)

C:\Users\Me\Anaconda\lib\site-packages\scipy\optimize\__init__.py in <module>()
    174 
    175 from .optimize import *
--> 176 from ._minimize import *
    177 from ._root import *
    178 from .minpack import *

C:\Users\Me\Anaconda\lib\site-packages\scipy\optimize\_minimize.py in <module>()
     30 # constrained minimization
     31 from .lbfgsb import _minimize_lbfgsb
---> 32 from .tnc import _minimize_tnc
     33 from .cobyla import _minimize_cobyla
     34 from .slsqp import _minimize_slsqp

C:\Users\Me\Anaconda\lib\site-packages\scipy\optimize\tnc.py in <module>()
     35 from __future__ import division, print_function, absolute_import
     36 
---> 37 from scipy.optimize import moduleTNC, approx_fprime
     38 from .optimize import MemoizeJac, OptimizeResult, _check_unknown_options
     39 from numpy import inf, array, zeros, asfarray

ImportError: cannot import name moduleTNC

如果我删除导致错误的行,那么我导致导入seaborn等错误...

我做错了什么?我该如何解决?

2 个答案:

答案 0 :(得分:6)

我发现底层的pyd文件名为moduletnc.pyd而不是moduleTNC.pyd。当我把最后三个字母大写时,问题就解决了。

答案 1 :(得分:4)

试试conda install -f scipy。这将迫使conda重新安装scipy。