Python - Patsy显然安装但python找不到它?

时间:2016-03-04 04:26:16

标签: python enthought statsmodels patsy

所以我的statsmodels安装非常混乱 - 我实际上必须自己将文件夹移动到Enthought的site-packages文件夹中。但无论如何,当我选择import statsmodels.api as smapi时,我会收到以下错误消息列表:

ImportError                               Traceback (most recent call last)
/home/joshuajoseph/Desktop/ANU PhD 2016 onwards/msagnfracs.py in <module>()
      9 import matplotlib.cm as cm #colour maps for plotting
     10 from operator import truediv #to divide lists
---> 11 import statsmodels.api as smapi
     12 import statsmodels.graphics as smgraphics
     13 

/home/joshuajoseph/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/statsmodels/api.py in <module>()
      3 from . import tools
      4 from .tools.tools import add_constant, categorical
----> 5 from . import regression
      6 from .regression.linear_model import OLS, GLS, WLS, GLSAR
      7 from .regression.quantile_regression import QuantReg

/home/joshuajoseph/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/statsmodels/regression/__init__.py in <module>()
----> 1 from .linear_model import yule_walker
      2 
      3 from statsmodels import NoseWrapper as Tester
      4 test = Tester().test

/home/joshuajoseph/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/statsmodels/regression/linear_model.py in <module>()
     50                                           cache_readonly,
     51                                           cache_writable)
---> 52 import statsmodels.base.model as base
     53 import statsmodels.base.wrapper as wrap
     54 from statsmodels.emplike.elregress import _ELRegOpts

/home/joshuajoseph/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/statsmodels/base/model.py in <module>()
      9 import statsmodels.base.wrapper as wrap
     10 from statsmodels.tools.numdiff import approx_fprime
---> 11 from statsmodels.formula import handle_formula_data
     12 from statsmodels.compat.numpy import np_matrix_rank
     13 from statsmodels.base.optimizer import Optimizer

/home/joshuajoseph/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/statsmodels/formula/__init__.py in <module>()
      2 test = Tester().test
      3 
----> 4 from .formulatools import handle_formula_data

/home/joshuajoseph/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/statsmodels/formula/formulatools.py in <module>()
      1 from statsmodels.compat.python import iterkeys
      2 import statsmodels.tools.data as data_util
----> 3 from patsy import dmatrices, NAAction
      4 import numpy as np
      5 

ImportError: No module named patsy 

所以看起来patsy没有安装。但当我pip install patsy时,我得到以下内容:

Requirement already satisfied (use --upgrade to upgrade): patsy in ./Enthought/Canopy_64bit/User/lib/python2.7/site-packages/patsy-0.4.1-py2.7.egg Requirement already satisfied (use --upgrade to upgrade): six in ./Enthought/Canopy_64bit/User/lib/python2.7/site-packages (from patsy) Requirement already satisfied (use --upgrade to upgrade): numpy in ./Enthought/Canopy_64bit/User/lib/python2.7/site-packages (from patsy)

并检入我的site-packages文件夹,我看到了:

patsy-0.4.1-py2.7.egg

上面的代码指向的是什么。但就是这样。仅凭这一点显然无法解决我的statsmodels问题,但我无法再安装patsy。如果我尝试升级它(pip install --upgrade patsy),我会得到这个:

Requirement already up-to-date: patsy in ./patsy-0.4.1-py2.7.egg Requirement already up-to-date: six in /home/joshuajoseph/Enthought/Canopy_64bit/User/lib/python2.7/site-packages (from patsy) Requirement already up-to-date: numpy in /home/joshuajoseph/Enthought/Canopy_64bit/User/lib/python2.7/site-packages (from patsy)

任何人都可以帮我弄清楚发生了什么事吗?

1 个答案:

答案 0 :(得分:0)

转到安装解释器的文件夹。就我而言,我的翻译是康达。因此,我在 C:\Users\%Username% 文件夹的 AppData 文件夹中找到了它。

  • 打开包含 _conda.exe 或您安装的解释器的文件夹
  • 假设您已经为解释器设置了环境,请转到 envs 文件夹。然后该文件夹应该在那里
  • 遵循其中的序列 myenv \ Lib \ site-packages 。在此目录中,将显示您环境中安装的所有软件包。
  • 如果不存在patsy文件夹,请再次进入解释器的目录,然后转到该目录 Lib \ site-packages 。最有可能在这里找到安装的软件包。
  • 只需找到文件: patsy patsy-0.5.1-py3.7.egg-info
  • 复制它们并将其粘贴到此目录 myenv \ Lib \ site-packages 中。

对我有用。我希望它也对您有用