History saving thread error when trying to open Pandas - python

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

Related

Error while using jupyter-datatables plugin in Jupyter Notebook

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.

Why won't basic code execute in Jupiter (import pandas as pd)?

I just downloaded Anaconda on a new laptop (have used Python many times before), and I currently can't run any code in Jupiter Notebooks. I am stuck in [*] no matter how simple the code (i.e. import pandas as pd or say x=1). Any suggestions on how to fix this? So far I have tried restarting Anaconda and shutting down the code in the running tab.
Based on the logs, take a look at this related question. Otherwise, googling python3 ERROR:tornado.general:Uncaught exception in ZMQStream may help.
I found the answer. The solution is not anywhere on stack overflow or Google. The answer to this problem is only on YouTube, which I found slightly surprising. Essentially, I had two versions of Anaconda, because it would seem that Macs come with an older version of Anaconda already installed in a hidden file called opt. I had to locate this file and then delete it in the terminal. Once Anaconda was completely removed, I was able to re-download Anaconda and then Jupyter was able to launch smoothly.
For anyone else having this problem you can find the solution here: https://www.youtube.com/watch?v=SJ_JTgq8-m8

Python import pandas not working when used within .bat file

I had the following issue that was giving me a lot of troubles. I managed to solve it after 2 1/2 hours and to spare some poor soul the same waste of time I wanted to show how I resolved it.
Loading a python file inside a .bat file was usually working quite well. However, I encountered issues when I tried to import pandas.
Code could look like this
import pandas as pd
print ("hello")
and the following result in the cmd prompt would be
ImportError: Unable to import required dependencies:
numpy:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.
We have compiled some common reasons and troubleshooting tips at:
https://numpy.org/devdocs/user/troubleshooting-importerror.html
My .bat file would look like
#echo off
"C:\Users\myUserName\Anaconda3\python.exe" "C:\path to .py file\MyPythonFile.py"
pause
To solve this I tried a variety of things like playing around with paths within windows and a large variety of other things.
After I opened python.exe within the Anaconda3 folder, I received
Warning:
This Python interpreter is in a conda environment, but the environment has
not been activated. Libraries may fail to load. To activate this environment
please see https://conda.io/activation
I found myself unable to resolve this within the command prompt but I managed to finally understand the core problem. With Anaconda3 being unactivated, it would never import pandas as intented while other imports were working as intented.
The solution that ended up working was adding the path of the activate.bat file inside the Anaconda3 folder. So the final .bat file would look like
#echo off
call "C:\Users\myUserName\Anaconda3\Scripts\activate.bat"
"C:\Users\myUserName\Anaconda3\python.exe" "C:\path to my Python Script\MyPythonFile.py"
pause
In a ideal scenario, I would be able to keep it activated but calling it within the .bat file is a adequate enough solution for me and may be enough for you too.

Jupyter on Anaconada on OSX, cells not showing results in browser

Opening Jupyter 6.0.2 from Anaconda Navigator 1.9.12, on OSX 10.13.6, Cells in notebooks on "run cell", do not show results.
It seems the standard output of a cell upon running can not be returned to the notebook in the browser to be displayed.
This seems a small technical issue, but after many several hours and days, I can not resolve.
Experience of this behaviour first comes with downloading a workbook (scipy_con_2019-master.zip, open Jupyter notebook "2_Gaussian_HMM_INSTRUCTOR.ipynb" ).
Upon opening, this initially shows results below the various code cells. Working through from the beginning using run (Run Cell), as each cell is calculated the results disappear. They are no longer shown. Thus preventing play, adaption, explore, learning.
To remove the possibility this behaviour is something to do with the downloaded notebooks, I created a new notebook with basic cell contents with simple commands like:
a=10
print(a)
or something as simple as
2*3
Upon run, same behaviour. No answer is returned for display below the code cell.
I note the integer number in brackets on far left does increase by 1 with each use of Run (run cell).
A full "stop kernal" and re-run all cells from the beginning, simply enforces behaviour to all cells in the downloaded notebook. That is, all results in the downloaded notebook all disappear.
Noting this behaviour is consistent to a downloaded notebook and a new created notebook, I suspect it is local settings, or conflict or set up issue.
As part of problem solving:
• I have ensured downloaded notebooks are identified as "trusted", and then re-opened and begun again. This makes no difference.
• This behaviour is with a full fresh download of Anaconda in the weeks before, around 20 May 2021. (Done in view of Navigator application would not complete an update as it requested. Full reinstall to update.)
• Is this a browser issue? Using Safari or Firefox as browser makes no difference to this behaviour.
• Search of key words, and key fault line in terminal, on Google search, or stack overflow or Superuser were not successful in finding a relatable solution.
Looking in terminal opened for each Jupyter session, I get the following identified error consistently, hence I think this is helpful to resolve the source of this issue, though beyond my limited coding knowledge to interpret and resolve the issue.
Traceback (most recent call last):
File "/anaconda3/lib/python3.7/site-packages/tornado/websocket.py", line 546, in run_callback
result = callback(*args, **kwargs)
File "/anaconda3/lib/python3.7/site-packages/notebook/services/kernels/handlers.py", line 274, in open
self.create_stream()
File "/anaconda3/lib/python3.7/site-packages/notebook/services/kernels/handlers.py", line 127, in create_stream
meth = getattr(km, 'connect' + channel)
AttributeError: 'MappingKernelManager' object has no attribute 'connect_control'
I am wondering if the issue relates to permissions or an incompatable component, or possibly arising in view of security upgrades in Jupyter (those pages read to seek answer to this). It seems the standard output of a cell upon running can not be returned to the notebook in the browser to be displayed.
I have posted this issue first on the ContinuumIO/anaconda - issues git hub page: here however I do not think this site is very active.
Solution was to download the recent newer release: Anaconda3-2021.05-MacOSX-x86_64.pkg once again.
Install initially failed. Then seemed to work, as in files were copied, then advised install had failed.
I noted an older master Anaconda file on the HD (highest level on HD) had not been updated since 2018. Hence, clearly this was not being updated by the recent installation process.
Deleted that Anaconda folder.
Then the install of the latest release did work.
It was not immediately easy to find where the new Anaconda files were installed.
The new installation was in the OSX User account folder, in a folder called "opt".
Now 1+1 shows the answer in a Jupyter file. Joy.

Visual Studio Code gives error when using Data Viewer: "Python package 'pandas' is required for viewing data"

I am running a python notebook in VS Code (see image). It runs fine but when I try to inspect a dataframe with the Data Viewer I get:
"Python package 'pandas' is required for viewing data."
The package is installed, otherwise, the code would not work and the data frames would not be present in the variable panel. When I click on "Install" I get: "Error: All data science packages require an interpreter be passed in"
I only have two environments, Anaconda and one created by VS code. I have tried selecting either one and nothing changes, code runs on both and I get the same errors on both.
Any ideas on how to fix this problem?
EDIT: The previous question Viewing data in the VSCode variable explorer requires pandas does not solve my issue. As mentioned above I have selected different environments without fixing it.
EDIT 2: Updating pandas did not fix it either. It was only solved by updating Anaconda, as suggested by Mrinal Roy.
This answer on a similar issue Viewing data in the VSCode variable explorer requires pandas mentioned it was fixed around a year ago.
It seems that the version.release string of pandas I was using includes characters that are not correctly parsed by the extension. They mentioned that it was going to be addressed yesterday in the Insider version. Looking forward to validating.
So, you probably have an older version of Anaconda or VS Code. Otherwise, what version of pandas do you have in both conda environments? VS Code Data Viewer requires pandas package 0.20 or later. Try upgrading it and related packages to the latest and check.

Categories

Resources