I am working with some data frames and recently came across jupyter-datatables plugin that gives a better look and feel of data frames when loaded into jupyter notebook.
so the below commands worked well for me for the first time-
pip install jupyter-require
pip install jupyter-datatables
from jupyter_datatables import init_datatables_mode
init_datatables_mode()
but now I am facing issues while loading the tables and getting error messages like the ones highlighted below:
OR this -
I am tired of reloading it ..sometimes it works but mostly it doesn't.
Tried finding answers but no luck.
Related
I am using Python in a Jupyter Lab notebook in a Docker container. I have the following code in one cell:
import numpy as np
import os
import pandas as pd
Then I run the following cell:
!pipreqs /app/loaded_reqs
and get:
INFO: Successfully saved requirements file in /app/loaded_reqs/requirements.txt
But when I open the requirements.txt, it shows up empty/blank. I expected numpy, os and pandas to be in this requirements.txt file. Why might it not be working?
According to this Medium post by Iván Lengyel, pipreqs doesn't support Jupyter notebooks. (This issue in in the pipreqs repo, open since 2016 convinces me of the veracity of that assertion. Nicely, the issue post also suggests the solution I had already found when searching the terms 'pipreqs jupyter' at Google.) Plus, importantly you generally don't use tools that act on notebook files inside the notebook you are trying to use. (Or at least it is something to always watch out for, [or test if possible], similar in a way to avoiding iterating on a list you are modifying in the loop.)
Solution -- use pipreqsnb instead:
In that Medium post saying it doesn't work with notebooks, Iván Lengyel proffers a wrapper for it that works for notebooks. So in the terminal outside the notebook, but in the same environment (inside the docker container, in your case), install pipreqsnb via pip install pipreqsnb. Then run it pointing it at your specific notebook file. I'll give an example in the next paragraph.
I just tried it and it worked in temporary sessions launched from here by pressing launch binder badge there. When the session came up, I opened a terminal and ran pip install pipreqsnb and then pipreqsnb index.ipynb. That first time I saw requirements.txt get made with details on the versions of matplotlib, numpy, scipy, and seaborn. To fully test it was working, I opened index.ipynb in the running session and added a cell with import pandas as pd typed in it and saved the notebook. Then I shutdown the kernel and over in the terminal ran, pipreqsnb index.ipynb. When I re-examined the requirements.txt file now pandas has been added with details about the versions.
More about maybe why !pipreqs /app/loaded_reqs failed:
I had the idea that maybe you needed to save the notebook first after adding the import statements cell? However, nevermind. That still won't help because as stated here pipreqs, and further confirmed at the pipreqs issues list doesn't support Jupyter notebooks.
Also, keep in mind the use of the exclamation in a notebook to run a command in the shell doesn't mean that shell will be in the same environment as the kernel of the notebook, see the second paragraph here to more perspective on that. (This can be useful to understand for future things though, such as why you want to use the %pip or %conda magic commands when installing from inside a notebook, see here, and not put an exclamation point in front of that command in modern Jupyter.)
Or inside the notebook at the end, I'd suggest trying %watermark --iversions, see watermark. And then making some code to generate the requirements.txt from that. (Also, I had seen there was bug in that related to some packages imported with from X import Y, see here.)
Or I'd suggest trying %pip freeze inside the notebook for the full environment information. Not just what the file needs, though.
Currently I am working on a project with Jupyter Notebook in which I need to run a matlab script (.m) which includes a function that provides me with data which i try to solve with a tensorflow model afterwards. I can set up an environment that runs the matlab code an gives me the data and I can set up an environment that does the tensorflow thing but my problem is I can`t do it in the same environment.
Here is the setup and the problems. I am using matlab.engine which I installed like described here: https://de.mathworks.com/help/matlab/matlab_external/install-the-matlab-engine-for-python.html
To run my Jupyter Notebook I first navigate to the location where my python.exe and the matlab files are lying ("C:\Users\Philipp\AppData\Local\Programs\Python\Python37-32\Scripts"). If I try to run pip install tensorflow (in Anaconda Prompt) I got a lot of different errors like the following. Conda install works but even when it is installed i can`t import it.
ImportError: No module named 'tensorflow.core' or
ERROR: Could not find a version that satisfies the requirement tensorflow or just No module named 'tensorflow'
I searched for all those problems but nothing helped me. I think this has something to do with the directory I am working in and I know it is bad but I have no idea how to change that. The error also occurs in different environments.
Have you tried running !pip install tensorflow directly in Jupyter Notebook? It's a temporary workaround, but I am having the same problems and this one helped. Remember to comment it out after installation, so you wont re-run it by accident.
I found a solution to my problem. For this I needed a Jupyter Notebook and an external .py script that I design as a Flask. I can luckily run those in different environments. I past and request the data from the server by using "get" and "post".
If someone still has another idea to do all this in one JN, I would still be happy about answers.
I was trying to use the package called LUX for Python. I followed this tutorial. So it was pretty simple, I just had to import some csv and when I called my data, I would be able to see multiple graphs. The problem is that I do everything and nothing shows up for me.
I was using Melbourne House Market data, and this is my script so far:
# firstly, we install package and extensions
!pip install lux-api
!jupyter nbextension install --py luxwidget
!jupyter nbextension enable --py luxwidget
# then, load the packages
import lux
import pandas as pd
# load data
melb_data = pd.read_csv("melb_data.csv")
So far so good... at least, I thought so. After doing these things, when we see the tutorial mentioned in the begining of this question, it mentions that if we call the dataframe now, instead of appearing only the dataset, we would be able to see some graphics as well. But that didn't happen to me. I know screenshots are not the best choice, but this is what I see:
As you can see, there is the Toggle button, but it is only working to hide the table. there isn't the graphs I saw in the tutorial. I also tried to follow this tutorial as well, but there isn't anything new there.
Any ideas on what I'm missing here? Why I can't find a way to make this package work?
It seems that you have not installed the JuypterLab extension. It is described in the README file that you linked, here. You will need to execute the following two commands:
jupyter labextension install #jupyter-widgets/jupyterlab-manager
jupyter labextension install luxwidget
and then restart JupyterLab. The prerequisite here is having a JupyterLab 2.x or 3.x and Node.js installed (while many extensions for JupyterLab 3.x do not require node.js any longer, this one still does - as it seems).
I just installed IPython on a remote desktop at work. I had to create a shortcut on my desktop to connect to IPython because the remote desktop does not have internet access. I am able to successfully open the IPython notebook. However, when I try to import pandas
import pandas as pd
I get this error that I have never seen before
The history saving thread hit an unexpected error (OperationalError('database or disk is full',)).History will not be written to the database.
Does this error relate to how it was installed on the remote desktop?
I suffered from this problem for a long time. My dirty fix was to simply restart the kernel and go about my work. However, I did find a way which eliminated it for good. This question seems to have mixed answers for different users. I'll try to list all based on answers elsewhere (all links at the end).
So the issue seems to be because of a certain nbsignatures.db file. And we need to simply remove it to solve the issue. You may find the file here in any one of the locations:
~/.local/share/jupyter/nbsignatures.db (I found mine here)
~/.ipython/profile_default/security/nbsignatures.db
~/Library/Jupyter/nbsignatures.db
All links:
https://github.com/ipython/ipython/issues/9293
IPython Notebook error: Error loading notebook
I keep getting an error when trying to run code from one of my IPython notebooks (the notebooks themselves open up fine, I'm just unable to run any code and view the output).
The complete error is:
ERROR:tornado.access:500 POST /api/sessions (127.0.0.1) 13.01ms referrer=http://127.0.0.1:8888/notebooks/untitled0.ipynb.
I'm running Python 3.3.5, IPython 2.0.0 via an install from easy_install on a windows 8 machine.
I tried reinstalling (uninstall via pip, reinstall via easy_install) the tornado package, IPython, it was of no use.
Any help is greatly appreciated, thank you.
When I used anaconda, I met a similar problem .
Try
pip install simplejson
This works for me
This page talks about a similar problem and solution.
https://github.com/ipython/ipython/issues/1966/
Good Luck!!!
I was using Holoviews package in the IPynb and I was caught by similar error. Then I found that if try to plot a dataframe in the server rather than a "Series", this error shows up. I dont know thw complete reason for this, but to all those who are getting the similar error,
kindly change your data to Series and then plot it in server
Hope it works for you too.