I´m new in coding and for streamlit
I wanted to add aggrid
But when i try to run my code i get a JSON error that i have tried to fix
How can i fix my Attributeerror JSON?
I have uninstalled and reinstalled
pip uninstall streamlit-aggrid
pip install streamlit-aggrid
Nothing helps:
From the code for Aggrid:
import pandas as pd
import streamlit as st
import streamlit.components.v1 as components
from st_aggrid import GridOptionsBuilder, AgGrid, GridUpdateMode, DataReturnMode
and the lines for Aggrid configuration:
# Define AgGrid configuration
gb = GridOptionsBuilder.from_dataframe(df_selection)
gb.configure_default_column(groupable=True, value=True, enableRowGroup=True, aggFunc='sum', editable=True)
gridOptions = gb.build()
# Render AgGrid
components.html(AgGrid(df_selection, gridOptions=gridOptions, width='100%', height='500px', data_return_mode=DataReturnMode.JSON).get_html(),height=800)
Related
I have utils.py and there are two functions: runrealcmd, mol_with_atom_index
If I try to import the two function with the following code:
from utils import mol_with_atom_index, runrealcmd
It fails to import runrealcmd. The error message is like below:
ImportError: cannot import name 'runrealcmd' from 'utils'
However, if I try to import only the mol_with_atom_index with the following code:
from utils import mol_with_atom_index
It successes. The function of mol_with_atom_index can be imported in Jupyter notebook.
However, the function of runrealcmd cannot be imported in Jupyter notebook although both of the two functions are in the same utils.py file.
ImportError: cannot import name 'runrealcmd' from 'utils'
utils.py
from subprocess import Popen, PIPE, STDOUT
from IPython.core.magic import register_line_magic
#register_line_magic
def runrealcmd(command):
# Display instantly: https://stackoverflow.com/questions/52545512/realtime-output-from-a-shell-command-in-jupyter-notebook
process = Popen(command, stdout=PIPE, shell=True, stderr=STDOUT, bufsize=1, close_fds=True)
for line in iter(process.stdout.readline, b''):
print(line.rstrip().decode('utf-8'))
process.stdout.close()
process.wait()
def mol_with_atom_index(mol):
for atom in mol.GetAtoms():
atom.SetAtomMapNum(atom.GetIdx())
return mol
(Jupyter notebook) If you want to import the same-named function (previously imported with the same name) from the other path, you should restart the kernel first.
I'm trying to use a recorded case in OpenMDAO contained in "my_file.db"
when i execute the following code:
import openmdao.api as om
cr = om.CaseReader('my_file.db')
I get the following error:
ModuleNotFoundError: No module named 'groups'
'groups' is a folder from the openMDAO code that I used to record the case and now I'm trying to import it from a different directory. How can I redefine the path for om.CaseReader to look for the modules it needs?
try setting your PYTHONPATH, as discussed here:
https://bic-berkeley.github.io/psych-214-fall-2016/using_pythonpath.html
Solved using:
import os
dirname = os.path.dirname(__file__)
import sys
sys.path.append( dirname )
I am having trouble importing TFBertModel, BertConfig, BertTokenizerFast. I tried the latest version of transformers, tokenizer==0.7.0, and transformers.modeling_bert but they do not seem to work. I get the error
from transformers import TFBertModel, BertConfig, BertTokenizerFast
ImportError: cannot import name 'TFBertModel' from 'transformers' (unknown location)
Any ideas for a fix? Thanks!
Do you have Tensorflow 2 installed? The model you are trying to import required Tensorflow
I am trying to use a Python block in my R markdown document. Below is what I have been trying:
"""{r setup, include=FALSE}
require(reticulate)
use_python("/Users/hyunjindominiquecho/opt/anaconda3", required = T)
"""
"""{python}
# import the necessary python packages
import numpy as np
import pandas as pd
import scipy.stats as st
from rpy2 import robjects
import math
from scipy.optimize import newton
import torch
from pandas import dataframe
from statistics import mean
"""
but when I try to do this, R studio shows the following error:
Error in system2(command = python, args = paste0("\"", config_script, :
error in running command
How can I resolve this issue? Thank you,
What if you did:
```{python, engine.path = '/Users/hyunjindominiquecho/opt/anaconda3'}
import sys
print(sys.version)
```
What happens when you only run the first chunk? Do you still get the same error?
I try to import the following functions:
import numpy as np
def load_labels(path):
y = np.load(path)
return y
def print_sentence():
print("hi")
from a Jupyter notebook, with name "save_load" into another Jupyter notebook with the following code:
!pip install import-ipynb
import import_ipynb
import save_load
from save_load import load_labels, print_sentence
The function print_sentence works fine in the notebook, but with the function load_labels I receive the following error:
NameError: name 'np' is not defined
What could be the reason for this error? I've imported numpy as np in both notebooks.
In "save_load" instead of import numpy as np try import numpy, it worked for me.
You can try this:
import numpy as np
or
from numpy import *
I had the same problem when I was fixing my codes on VScode. Try saving the file. Then run it again.