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!
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.
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.
Related
I tried to use the demo of the DDSP model developed by Google Research in colab, but there was an error during the import stage, so I couldn't import it.
This problem didn't happen until recently, but suddenly an error is occurring.
`
##title #Install and Import
##markdown Install ddsp, define some helper functions, and download the model. This transfers a lot of data and _should take a minute or two_.
print('Installing from pip package...')
!pip install -qU ddsp==1.6.5 "hmmlearn<=0.2.7"
# Ignore a bunch of deprecation warnings
import warnings
warnings.filterwarnings("ignore")
import copy
import os
import time
import crepe
import ddsp
import ddsp.training
from ddsp.colab.colab_utils import (
auto_tune, get_tuning_factor, download,
play, record, specplot, upload,
DEFAULT_SAMPLE_RATE)
from ddsp.training.postprocessing import (
detect_notes, fit_quantile_transform
)
import gin
from google.colab import files
import librosa
import matplotlib.pyplot as plt
import numpy as np
import pickle
import tensorflow.compat.v2 as tf
import tensorflow_datasets as tfds
# Helper Functions
sample_rate = DEFAULT_SAMPLE_RATE # 16000
print('Done!')
`
It seems to be a problem with the version, so I tried to upgrade the pip and install the pip before importing the module according to the guide, but it still hasn't been solved.
Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
WARNING: etils 0.9.0 does not provide the extra 'epath-no-tf'
A similar warning will continue to be displayed below...
`
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-2-fb97381ec3fd> in <module>
13 import time
14
---> 15 import crepe
16 import ddsp
17 import ddsp.training
ModuleNotFoundError: No module named 'crepe'
---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.
To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------------------------------------------------
`
This error is output if I stop importing.
I am trying to run a python code using VS code, I noticed that the result is different from the local terminal.
here is the code:
import tensorflow as tf
from tensorflow import keras
import os
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
os.environ['TF_CPP_MIN_LOG_LEVEL']='2'
a=tf.constant(10)
print(f"a = {a}")
its successfully running using my local terminal and I am having the error below while using my vs code terminal.
File "00-test.py", line 11
print(f"a = {a}")
^```
you can check if the two pythons in vscode terminal and local terminal have the same version,or with the same enviro
In a python script file I have:
import sklearn
iris=sklearn.datasets.load_iris()
This works:
$ ipython <this script file>
But now I do in the script file:
import sklearn as sk
iris=sk.datasets.load_iris()
If I do the same as above, I see:
AttributeError: module 'sklearn' has no attribute 'datasets'
This is what I do not understand. Also in interactive ipython the last import and assignment work!
Also:
import scipy as sp
p1=sp.special.expit(Phi#w)
works in a script file (given to ipython)! Looks like the same as above with sklearn where it did not work.
I am trying to import Image from PILLOW.
from PILLOW import Image
im = Image.open("bride.jpg")
im.rotate(45).show()
Undefined function 'from' for input arguments of type 'char'.
>> import PIL.Image
im = Image.open("bride.jpg")
im.rotate(45).show()
Error using import
Import argument 'PIL.Image' cannot be found or cannot be imported.
Undefined function 'from' for input arguments of type 'char'.
I keep getting the same error. Am I using the wrong import statement?
EDIT:
I noticed something else. when i browse through my C:/ drive and look inside the folders where Pip, and PIL ,etc is. There is nothing inside them. Even when i copy a file with stuff to that area, and open that new file, i cant see any of the stuff inside. When i copy it though, and the green bar goes it shows data being transferred.
The Code:
https://hub.gke.mybinder.org/user/alexmill-website_notebooks-fcqkeh7a/notebooks/fourier-spinning-circles.ipynb#
Example:
enter code here
from PIL import Image, ImageEnhance
# Main imports/Initialization
%matplotlib inline
import matplotlib
from matplotlib import animation, rc
import matplotlib.pyplot as plt
from matplotlib.pyplot import imshow
from IPython.display import HTML
import numpy as np
from PIL import Image, ImageEnhance
import requests
from io import BytesIO
from copy import deepcopy
from scipy.spatial import distance
from scipy.interpolate import UnivariateSpline
from copy import deepcopy
# Default figure size in notebook
matplotlib.rcParams['figure.figsize'] = (6,6)
matplotlib.rcParams['image.aspect'] = 'equal'
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-16-7c75157a7886> in <module>
7 from IPython.display import HTML
8 import numpy as np
----> 9 from PIL import Image, ImageEnhance
10 import requests
11 from io import BytesIO
ModuleNotFoundError: No module named 'PIL'
The reason your binder doesn't work is because your requirements.txt looks like this:
matplotlib==2.0.2
requests==2.20.0
Pillow==5.0.0
numpy==1.13.0
scipy==0.19.0
pandas==0.20.2
scikit-learn==0.18.1
tzlocal-1.5.1
This line:
tzlocal-1.5.1
Probably breaks the binder dependency install. Another thing is that these are very specific versions that might generate too specific dependencies (ref. here). I recommend changing it to this:
matplotlib
requests
pillow
numpy
scipy
pandas
scikit-learn
tzlocal
At least your binder started working when I did that.
Locally you will just have to run pip install -r requirements.txt with an admin command prompt and then your local Jupyter installation should automatically work, at least it did when I cloned your notebook to a Windows VM.
I want to incorporate Plotly graphs in my Jupyter notebook but I'm getting a 404 error when I try to display a graph:
According to this post
import sys; print(sys.executable)
Gives me this location for Python. I have the two Pandoc files in this directory as and all the files needed as mentioned on Plotly's page.
C:\Users\name\AppData\Local\Continuum\Anaconda3\python.exe
I have also tried reinstalling Anaconda and Pandoc but I'm still getting this error. Any thoughts?
Do you have a plotly account? You may need to login into it within your notebook with something similar to this:
import plotly
plotly.tools.set_config_file(plotly_domain='domain')
from plotly import __version__
from plotly.offline import download_plotlyjs, init_notebook_mode, iplot
import plotly.plotly as py
print __version__ # requires version >= 1.9.0
import plotly.graph_objs as go
init_notebook_mode() # run at the start of every ipython notebook to use plotly.offline
# this injects the plotly.js source files into the notebook
py.sign_in(username='xxxx', api_key='xxxx')
I have the same issue in MacOS. In the console, it can be seen that it's looking for .html.embed but the file which is created is .html.
I have tried,
1) reinstalling Pandocs
2) Had to reinstall Cairo as package pbdZMQ was not getting installing properly.
This is the workaround I did,
p <- plot_ly(ds, x = x, y = y, mode = "markers", group = group, size = size)
htmlwidgets::saveWidget(as.widget(p), "index.html")
rawHTML <- paste(readLines("index.html"), collapse="\n")
display_html(rawHTML)
This is not the best solution, but for the time being this works for me.