3

When I run the following code in PyCharm on a Mac:

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()

There were some errors:

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

I'm new in Chainer and DQN. Could anyone help me edit this code to make it work? Thank you so much!

desertnaut
  • 57,590
  • 26
  • 140
  • 166
William
  • 3,724
  • 9
  • 43
  • 76
  • I don't know exactly about your error, but having used PyCharm from soo much time I would just say, check whether chainer and other libs are installed in PyCharm. Because if you have an interpreter in a virtual environment associated with a project and not set to globally on your system, you'll have to first install it from Settings -> Project Interpreter -> Install – TheSHETTY-Paradise Dec 30 '18 at 15:56
  • I’m using virtualenv do you think I need use conda? – William Dec 30 '18 at 16:32
  • 1
    This is a question about plotting, and it has actually nothing to do with `machine-learning`, `deep-learnng`, or `openblas` - kindly do not spam the tags (removed). – desertnaut Dec 30 '18 at 17:31

2 Answers2

15

It seems like you're trying to run plotly interactive functions (i prefix) in a normal Python code (i.e. not IPython Notebook). iplot provides an interactive graph with which you can play inside the notebook.

I'd start with removing iplot import and replacing it with normal plot. Also, remove iplot_mpl and init_notebook_mode from your imports.

Lukasz Tracewski
  • 10,794
  • 3
  • 34
  • 53
0

You can install 'ipython' in the virtual environment and then try running it directly from the terminal.

  • Activate the virtual environment
  • pip3 install ipython
  • python3 prog.py

Worked in my case.

Vivek
  • 192
  • 1
  • 3
  • 7