2017-08-06 60 views
0

我剛開始使用RodeoPython 3.6.2。但也有10的Windows下這裏進口statsmodels時是一個錯誤的腳本:Rodeo:ImportError:沒有名爲'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

UPDATE:

以下爲print(sys.pth)Rodeo輸出。有一條路徑爲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'] 
+0

你做了'pip install statsmodels'嗎? –

+0

在'statsmodels'下安裝'python setup.py install' – user938363

+0

嘗試'pip安裝statsmodels'並返回所有'require already'' – user938363

回答

0

您可能沒有最新版本的python2。要麼更新它,要麼改用python3。

To use python 3, use pip3 instead of pip. So run the following:

pip3 install statsmodels

0

我有同樣的問題。我通過將statsmodels路徑添加到rodes> preferences>環境變量來解決此問題。在我的情況下,路徑是「C:\ ProgramData \ Miniconda3 \ pkgs」。