Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Updated Anaconda, error message "cannot import name 'moduleTNC'" when importing scipy

I updated anaconda on windows using conda update anaconda. Now my my ipython notebook, which starts with

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
...

is giving me errors:

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

If I remove the line causing the error, then I get an error importing seaborn, etc...

What have I done wrong? How can I fix it?

like image 894
theQman Avatar asked Dec 06 '22 21:12

theQman


1 Answers

I spotted the underlying pyd file to be named moduletnc.pyd instead of moduleTNC.pyd. When I capitalized the last three letters, the problem was solved for me.

like image 96
user7316501 Avatar answered Apr 28 '23 04:04

user7316501