python - 导入错误 : `iplot` can only run inside an IPython Notebook

标签 python pycharm ipython chainer

当我在 Mac 上的 PyCharm 中运行以下代码时:

import numpy as np 
import pandas as pd 

from subprocess import check_output
print(check_output(["ls", "../input"]).decode("utf8"))


import time
import copy
import numpy as np
import pandas as pd
import chainer
import chainer.functions as F
import chainer.links as L
from plotly import tools
from plotly.graph_objs import *
from plotly.offline import init_notebook_mode, iplot, iplot_mpl
init_notebook_mode()
data = pd.read_csv('../input/Data/Stocks/goog.us.txt')
data['Date'] = pd.to_datetime(data['Date'])
data = data.set_index('Date')
print(data.index.min(), data.index.max())
data.head()

有一些错误:

UserWarning: Accelerate has been detected as a NumPy backend library.
vecLib, which is a part of Accelerate, is known not to work correctly with Chainer.
We recommend using other BLAS libraries such as OpenBLAS.
For details of the issue, please see
https://docs.chainer.org/en/stable/tips.html#mnist-example-does-not-converge-in-cpu-mode-on-mac-os-x.

Please be aware that Mac OS X is not an officially supported OS.

  ''')  # NOQA
Traceback (most recent call last):
  File "/Users/yindeyong/Desktop/PythonProjects/pythonstock/DQNStcok.py", line 33, in <module>
    init_notebook_mode()
  File "/Users/yindeyong/Desktop/PythonProjects/envs/stockenv/lib/python3.6/site-packages/plotly/offline/offline.py", line 250, in init_notebook_mode
    raise ImportError('`iplot` can only run inside an IPython Notebook.')
ImportError: `iplot` can only run inside an IPython Notebook.

Process finished with exit code 1

我是 Chainer 和 DQN 的新手。任何人都可以帮助我编辑此代码以使其工作吗?非常感谢!

最佳答案

您似乎正在尝试在普通 Python 代码(即不是 IPython Notebook)中运行情节交互函数(i 前缀)。 iplot 提供了一个交互式图形,您可以在笔记本中使用它。

我将从删除 iplot 导入并将其替换为正常的 plot 开始。此外,从导入中删除 iplot_mplinit_notebook_mode

关于python - 导入错误 : `iplot` can only run inside an IPython Notebook,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53978924/

相关文章:

python - 为什么我的 if age 语法不起作用? (初学者 Python)

python - 无法使用请求从网页获取特定项目

python - 带有 Anaconda 解释器的 Pycharm 中的可用包为空

python - 使用 %prun 对执行时间短的函数进行分析

python - 如何修复 IPython 的 "ImportError: no module named shell"错误

Python——读取文件后如何给出一个字符串值

python - 使用 python Pandas 进行数据重排 |根据重复索引创建列并填充列值

python - 是否有任何 Python2 的实现可以传递排序?

python - 如何让PyCharm IDE 为pygame 的子模块做代码补全?

python - 导入错误 : No module named 'selenium' in PyCharm