'DB2ExecutionContext_ibm_db' object has no attribute 'compiled_parameters' - sql

I ran into a problem while querying on ibm-db2 cloud.
I checked the db connection. The connection is okay but whenever I try to query something (anything) it gives me this error.
'DB2ExecutionContext_ibm_db' object has no attribute 'compiled_parameters'
a snapshot of the error -
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-22-ec7ae9958cc4> in <module>
......
......
~/conda/envs/python/lib/python3.6/site-packages/ibm_db_sa/ibm_db.py in pre_exec(self)
47 def pre_exec(self):
48 # if a single execute, check for outparams
---> 49 if len(self.compiled_parameters) == 1:
50 for bindparam in self.compiled.binds.values():
51 if bindparam.isoutparam:
AttributeError: 'DB2ExecutionContext_ibm_db' object has no attribute 'compiled_parameters'
Any solution ?

you could check for these installment if you haven't
!pip install sqlalchemy==1.3.9
!pip install ibm_db_sa
I got the same error and this helps

Related

How to fix __init__() got an unexpected keyword argument 'location' error in scanpy.pl.umap?

I am trying to run single-cell analysis on scanpy 1.9.1. When I try to run scanpy.pl.umap(adata, color=["PDGFRB","RGS5"], s = 30), I get the following error:
TypeError Traceback (most recent call last)
in
----> 1 sc.pl.umap(adata, color=["PDGFRB","RGS5"], s = 30)
5 frames
/usr/local/lib/python3.8/dist-packages/matplotlib/colorbar.py in init(self, ax, mappable, **kw)
1228 """
1229 Return colorbar data coordinates for the boundaries of
-> 1230 a proportional colorbar, plus extension lengths if required:
1231 """
1232 if (isinstance(self.norm, colors.BoundaryNorm) or
TypeError: init() got an unexpected keyword argument 'location'
And I get a blank color heat legend.
blank_color_heat_legend
I saw someone suggested using an older version of matplotlib for a similar problem. This error occurred in matplotlib 3.6.3, so I tried installing matplotlib 3.1.3 but it did not work either.
Any help will be appreciated!

When trying to create html report the program throws error in

When executing the below
profile = ProfileReport(df,title="Data Profile Report")
profile.to_file("data_profile_report.html")
Here is the exception thrown
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
c:\Projections 2022-08-16\Projections.py in <cell line: 4>()
102 # %%
103 #Creating EDA of data
104 profile = ProfileReport(df_cdap,title="CDAP Data Profile Report")
----> 105 profile.to_file("cdap_data_profile_report.html")
File c:\Users\fengq\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas_profiling\profile_report.py:257, in ProfileReport.to_file(self, output_file, silent)
254 self.config.html.assets_prefix = str(output_file.stem) + "_assets"
255 create_html_assets(self.config, output_file)
--> 257 data = self.to_html()
259 if output_file.suffix != ".html":
260 suffix = output_file.suffix
File c:\Users\fengq\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas_profiling\profile_report.py:368, in ProfileReport.to_html(self)
360 def to_html(self) -> str:
361 """Generate and return complete template as lengthy string
362 for using with frameworks.
363
(...)
366
367 """
--> 368 return self.html
...
--> 810 fig = manager.canvas.figure
811 if fig_label:
812 fig.set_label(fig_label)
AttributeError: 'NoneType' object has no attribute 'canvas'
I've tried to re-install python and reinstalling the dependencies for pandas-profiling but nothing seems to work so far. I've also tried downgrading python to python 3.9 and the matplotlib to an older version as well. It has not changed this error.
I notice that the error seems to be attributed to "manager.canvas.figure" but I'm not sure how to resolve it from that point onwards. Any help is greatly appreciated!
The problem resolved as I set the matplotlib to inline as per some comments that I was able to find on another forum. I'm still really interested to learn what causes this! Please feel free to answer and suggest other solutions! I would love to try them!

How to use _repr_html_ with pyspark 2.2 and python 2.7

I run the following line at my terminal and I got an error, but it works fine in jupyter notebook.
df._repr_html_()
Traceback (most recent call last):
File "", line 1, in
File "/usr/lib/spark/python/pyspark/sql/dataframe.py", line 1020, in getattr
"'%s' object has no attribute '%s'" % (self.class.name, name))
AttributeError: 'DataFrame' object has no attribute '_repr_html_'
It doesn't work on my terminal because it's not a visual interpreter, so I had to go through the data frame collecting the values I needed and creating a string like html. Then, I could attached to an email I send from python at the terminal and works fine.

tf.logging.__dict__[hparams.verbosity] / 10) KeyError: 'INFO'

Trying to run GitHub codes of nonlocal recurrent networks.
I am ending up getting this error. How to debug this error?
Traceback (most recent call last):
File "trainer.py", line 97, in
tf.logging.dict[hparams.verbosity] / 10)
KeyError: 'INFO'
tried editing codes. but not working.
On tensorflow version 1.14, below code will cause the error.
tf.logging.dict[hparams.verbosity]
So you can fix the code like below. It will be ok on tf 1.14.
getattr(tf.logging, hparams.verbosity)

Getting a EOF error when calling pd.read_pickle

Had a quick question regarding a pandas DataFrame and the pd.read_pickle() function. Basically, I have a large but simple Dataframe (333 mb). When I run pd.read_pickle on the dataframe, I am getting and EOFError.
Is there any way around this issue? What might be causing this?
I saw the same EOFError when I created a pickle using:
pandas.DataFrame.to_pickle('path.pkl', compression='bz2')
and then tried to read with:
pandas.read_pickle('path.pkl')
I fixed the issue by supplying the compression on read:
pandas.read_pickle('path.pkl', compression='bz2')
According to the Pandas docs:
compression : {‘infer’, ‘gzip’, ‘bz2’, ‘zip’, ‘xz’, None}, default ‘infer’
string representing the compression to use in the output file. By default,
infers from the file extension in specified path.
Thus, simply changing the path from 'path.pkl' to 'path.bz2' also fixed the problem.
I can confirm the valuable comment of greg_data:
When I encountered this error I worked out that it was due to the
initial pickling not having completed correctly. The pickle file was
created, but not finished correctly. Seems to me this is the only
possible source of the EOFError in pickle, that the pickle is
malformed, i.e. not finished.
My error during pickling was:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-40-263240bbee7e> in <module>()
----> 1 main()
<ipython-input-38-9b3c6d782a2a> in main()
43 with open("/content/drive/MyDrive/{}.file".format(tm.id), "wb") as f:
---> 44 pickle.dump(tm, f, pickle.HIGHEST_PROTOCOL)
45
46 print('Coherence:', get_coherence(tm, token_lists, 'c_v'))
TypeError: can't pickle weakref objects
And when reading that pickle file that was obviously not finished during pickling, the reported error occured:
pd.read_pickle(r'/content/drive/MyDrive/TEST_2021_06_01_10_23_02.file')
Error:
---------------------------------------------------------------------------
EOFError Traceback (most recent call last)
<ipython-input-41-460bdd0a2779> in <module>()
----> 1 object = pd.read_pickle(r'/content/drive/MyDrive/TEST_2021_06_01_10_23_02.file')
/usr/local/lib/python3.7/dist-packages/pandas/io/pickle.py in read_pickle(filepath_or_buffer, compression)
180 # We want to silence any warnings about, e.g. moved modules.
181 warnings.simplefilter("ignore", Warning)
--> 182 return pickle.load(f)
183 except excs_to_catch:
184 # e.g.
EOFError: Ran out of input