python - 奇怪 "ModuleNotFoundErrior no module named iexfinance"

标签 python pycharm

我在 Pycharm 社区版 2017.3.3 中运行此代码,它运行良好。但是,当我尝试从命令行运行它时,我得到:

“从 iexfinance 导入 get_historical_data ModuleNotFoundError 没有名为 iexfinance 的模块"

有什么想法吗?正如你可以猜到的,我真的! Python 新手。

<code>
from iexfinance import get_historical_data
from bokeh.plotting import figure, show, output_file
from bokeh.models.annotations import Title
from datetime import datetime
import pandas as pd
import matplotlib as plt
from datetime import date
from dateutil import parser
from datetime import datetime
import time
from math import pi
from pykalman import KalmanFilter
#This works in pycharm community but not from Command Line
ticker=input("Ticker: ")
start_date=input("Start Date: ")
end_date = input("End Date: ")
start_date = pd.to_datetime(start_date)
end_date = pd.to_datetime(end_date)
#Get rid of nsepy will use Quandl instead
df = get_historical_data(ticker, start=start_date, end=end_date, output_format='pandas')
#Show it
print(df)
kf = KalmanFilter(transition_matrices = [1],
                  observation_matrices = [1],
                  initial_state_mean = df['close'].values[0],
                  initial_state_covariance = 1,
                  observation_covariance=1,
                  transition_covariance=.01)
state_means,_ = kf.filter(df[['close']].values)
state_means = state_means.flatten()
df["date"] = pd.to_datetime(df.index)
mids = (df.open + df.close)/2
spans = abs(df.close-df.open)
inc = df.close > df.open
dec = df.open > df.close
w = 12*60*60*1000 
TOOLS = "pan,wheel_zoom,box_zoom,reset,save"
p = figure(x_axis_type="datetime", tools=TOOLS, plot_width=1000, toolbar_location="left",y_axis_label = "Price",
           x_axis_label = "Date")
p.segment(df.date, df.high, df.date, df.low, color="black")
p.rect(df.date[inc], mids[inc], w, spans[inc], fill_color='green', line_color="green")
p.rect(df.date[dec], mids[dec], w, spans[dec], fill_color='red', line_color="red")
p.line(df.date,state_means,line_width=1,line_color = 'blue',legend="Kalman filter")
t = Title()
t.text = 'Kalman Filter Estimation'
p.title = t
p.xaxis.major_label_orientation = pi/4
p.grid.grid_line_alpha=0.3
#Needed this
output_file(ticker + ".html")
show(p)

</code>

最佳答案

软件包已更新。导入函数如下:

from iexfinance.stocks import get_historical_data

我在usage examples中找到了它iexfinance documentation

关于python - 奇怪 "ModuleNotFoundErrior no module named iexfinance",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51558197/

相关文章:

Python Beautifulsoup get_text() 没有获取所有文本

python - 如何在 python pandas 数据框中搜索具有相同 ID 的所有值

python - Pandas 的数据框(Python)是否更接近 R 的数据框或数据表?

Python - 我的网络应用程序不断显示 "Hello World!"

ubuntu - pycharm 告诉我我安装了一个包但我不能使用那个包

python-3.x - PyCharm IDE 不会突出显示未声明的变量

python - “InMemoryUploadedFile”对象没有属性 'get'

python - 将组合框中选定的选项设置为变量,该变量随着组合框中选定的选项的变化而变化

intellij-idea - 限制核心使用 PyCharm

python - 调试时模拟 argparse 命令行参数输入