我刚开始在Python 3.6.2中使用Rodeo。但在Windows10下导入statsmodels时出现错误,脚本如下:
import pandas as pd
import statsmodels.api as sm
import pylab as pl
import numpy as np突出显示import statsmodels.api as sm并单击Run line时,会出现错误:
>>> import statsmodels.api as sm
ImportError: No module named 'statsmodels'
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-3-6030a6549dc0> in <module>()
----> 1 import statsmodels.api as sm
ImportError: No module named 'statsmodels'然后我从Github下载了statsmodels并安装了它。下面是pip list的输出
C:\Users\Documents\statsmodels-master\statsmodels-master>pip list
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
Cython (0.26)
numpy (1.13.1)
pandas (0.20.3)
patsy (0.4.1)
pip (9.0.1)
python-dateutil (2.6.1)
pytz (2017.2)
scipy (0.19.1)
setuptools (28.8.0)
six (1.10.0)
statsmodels (0.8.0)输出显示statsmodels 0.8.0已安装。但是仍然存在导入错误。看起来Rodeo很难看到statsmodels。
更新:
以下是Rodeo中print(sys.pth)的输出。这里有一条statsmodels的路径。
>>> print(sys.path)
['', 'C:\\Python36\\Scripts', 'c:\\python36\\lib\\site-packages\\statsmodels-0.8.0-py3.6-win-amd64.egg', 'C:\\Python36', 'C:\\Python36\\python36.zip', 'C:\\Python36\\DLLs', 'C:\\Python36\\lib', 'C:\\Python36\\lib\\site-packages', 'C:\\Python36\\lib\\site-packages\\patsy-0.4.1-py3.6.egg', 'C:\\Python36\\lib\\site-packages\\pandas-0.20.3-py3.6-win-amd64.egg', 'C:\\Python36\\lib\\site-packages\\six-1.10.0-py3.6.egg', 'C:\\Python36\\lib\\site-packages\\pytz-2017.2-py3.6.egg', 'C:\\Python36\\lib\\site-packages\\python_dateutil-2.6.1-py3.6.egg', 'C:\\Python36\\lib\\site-packages\\IPython\\extensions', 'C:\\Users\\JunC\\.ipython']发布于 2018-01-13 19:18:27
我也有同样的问题。我通过将statsmodel的路径添加到rodes>preferences>environment变量来解决这个问题。在我的例子中,路径是"C:\ProgramData\Miniconda3\pkgs“。
发布于 2017-09-25 17:17:06
您可能没有最新版本的python2。要么更新它,要么改用python3。
要使用Python3,请使用pip3而不是pip。因此,运行以下命令:
pip3 install statsmodels
https://stackoverflow.com/questions/45535621
复制相似问题