UnsupportedOperation: not writabl, in python while counting coins in chainsaw - python

What I'm trying to do is to print ot the total number of coins in blockchain.
I'm working with the examples from the Chainscan manual
Here is my code so far:
from chainscan import iter_blocks
total_btc = 0
for block in iter_blocks(show_progressbar = True):
coinbase_tx = next(iter(block.txs)) # the first tx is coinbase
total_btc += coinbase_tx.get_total_output_value()
print('Total %d satoshis (up to block height %d)' % (total_btc, block.height))
The Problem is that I get an UnsupportedOperation error. Here is the traceback:
UnsupportedOperation Traceback (most recent call last)
<ipython-input-3-2b54aca19755> in <module>()
1 total_btc = 0
----> 2 for block in iter_blocks(show_progressbar = True):
3 coinbase_tx = next(iter(block.txs)) # the first tx is coinbase
4 total_btc += coinbase_tx.get_total_output_value()
5 print('Total %d satoshis (up to block height %d)' % (total_btc, block.height))
/usr/local/lib/python3.5/dist-packages/chainscan/utils.py in iter_blocks(block_iter, **kwargs)
23 """
24 if block_iter is None:
---> 25 block_iter = LongestChainBlockIterator(**kwargs)
26 return block_iter
27
/usr/local/lib/python3.5/dist-packages/chainscan/scan.py in __init__(self, block_iter, height_safety_margin, block_filter, **kwargs)
322 """
323 if block_iter is None:
--> 324 block_iter = TopologicalBlockIterator(**kwargs)
325 self.block_iter = block_iter
326 if height_safety_margin is None:
/usr/local/lib/python3.5/dist-packages/chainscan/scan.py in __init__(self, rawfile_block_iter, **kwargs)
230 """
231 if rawfile_block_iter is None:
--> 232 rawfile_block_iter = RawFileBlockIterator(**kwargs)
233 self.rawfile_block_iter = rawfile_block_iter
234
/usr/local/lib/python3.5/dist-packages/chainscan/scan.py in __init__(self, raw_data_iter, **kwargs)
155 """
156 if raw_data_iter is None:
--> 157 raw_data_iter = RawDataIterator(**kwargs)
158 self.raw_data_iter = raw_data_iter
159
/usr/local/lib/python3.5/dist-packages/chainscan/rawfiles.py in __init__(self, raw_files_iter, use_mmap, **kwargs)
115 """
116 if raw_files_iter is None:
--> 117 raw_files_iter = RawFilesIterator(**kwargs)
118 self.raw_files_iter = raw_files_iter
119 self.use_mmap = use_mmap
.
/usr/local/lib/python3.5/dist-packages/click/utils.py in echo(message, file, nl, err, color)
257
258 if message:
--> 259 file.write(message)
260 file.flush()
261
UnsupportedOperation: not writable
Any ideas?
Thanks in advance.

Related

The 'Box' object has no attribute 'spaces'

I'm trying to implement a game class where you have to stay in the 49-51 number range as long as possible. The state space is given by a range from 0 to 100, the initial state is the number 47 or the number 53 (chosen randomly), and you can change the state of the environment by three actions - adding 0, adding 1 or adding -1. Also, after each action there is a random addition of 1 or -1
I need to choose an algorithm from the baseline3 library and train it. I train the PPO algorithm, but I get the following error:
The 'Box' object has no attribute 'spaces'.
Box has no 'spaces' attribute, what could be the problem?
import numpy as np
from stable_baselines3 import PPO
import random
from gym import Env
from gym.spaces import Discrete, Box
class CustomEnv(Env):
def __init__(self):
self.action_space = Discrete(3)
self.observation_space = Box(low=np.array([0]), high=np.array([100]))
self.state = 50 +- random.randint(-3, 3)
self.length = 120
def step(self, action):
self.state += action-1
self.length -= 1
if self.state >= 49 and self.state <= 51:
reward = 1
else:
reward = -1
if self.length <= 0:
done = True
else:
done = False
self.state += random.randint(-1, 1)
return self.state, reward, done, {}
def reset(self):
self.state = 50 +- random.randint(-3, 3)
self.length = 120
env = CustomEnv()
model = PPO("MultiInputPolicy", env)
model.learn(total_timesteps=20000)
AttributeError Traceback (most recent call last)
Input In [148], in <cell line: 41>()
38 self.length = 120
40 env = CustomEnv()
---> 41 model = PPO("MultiInputPolicy", env)
42 model.learn(total_timesteps=20000)
File E:\Anaconda\lib\site-packages\stable_baselines3\ppo\ppo.py:162, in PPO.__init__(self, policy, env, learning_rate, n_steps, batch_size, n_epochs, gamma, gae_lambda, clip_range, clip_range_vf, normalize_advantage, ent_coef, vf_coef, max_grad_norm, use_sde, sde_sample_freq, target_kl, tensorboard_log, create_eval_env, policy_kwargs, verbose, seed, device, _init_setup_model)
159 self.target_kl = target_kl
161 if _init_setup_model:
--> 162 self._setup_model()
File E:\Anaconda\lib\site-packages\stable_baselines3\ppo\ppo.py:165, in PPO._setup_model(self)
164 def _setup_model(self) -> None:
--> 165 super()._setup_model()
167 # Initialize schedules for policy/value clipping
168 self.clip_range = get_schedule_fn(self.clip_range)
File E:\Anaconda\lib\site-packages\stable_baselines3\common\on_policy_algorithm.py:117, in OnPolicyAlgorithm._setup_model(self)
106 buffer_cls = DictRolloutBuffer if isinstance(self.observation_space, gym.spaces.Dict) else RolloutBuffer
108 self.rollout_buffer = buffer_cls(
109 self.n_steps,
110 self.observation_space,
(...)
115 n_envs=self.n_envs,
116 )
--> 117 self.policy = self.policy_class( # pytype:disable=not-instantiable
118 self.observation_space,
119 self.action_space,
120 self.lr_schedule,
121 use_sde=self.use_sde,
122 **self.policy_kwargs # pytype:disable=not-instantiable
123 )
124 self.policy = self.policy.to(self.device)
File E:\Anaconda\lib\site-packages\stable_baselines3\common\policies.py:802, in MultiInputActorCriticPolicy.__init__(self, observation_space, action_space, lr_schedule, net_arch, activation_fn, ortho_init, use_sde, log_std_init, full_std, sde_net_arch, use_expln, squash_output, features_extractor_class, features_extractor_kwargs, normalize_images, optimizer_class, optimizer_kwargs)
782 def __init__(
783 self,
784 observation_space: gym.spaces.Dict,
(...)
800 optimizer_kwargs: Optional[Dict[str, Any]] = None,
801 ):
--> 802 super().__init__(
803 observation_space,
804 action_space,
805 lr_schedule,
806 net_arch,
807 activation_fn,
808 ortho_init,
809 use_sde,
810 log_std_init,
811 full_std,
812 sde_net_arch,
813 use_expln,
814 squash_output,
815 features_extractor_class,
816 features_extractor_kwargs,
817 normalize_images,
818 optimizer_class,
819 optimizer_kwargs,
820 )
File E:\Anaconda\lib\site-packages\stable_baselines3\common\policies.py:461, in ActorCriticPolicy.__init__(self, observation_space, action_space, lr_schedule, net_arch, activation_fn, ortho_init, use_sde, log_std_init, full_std, sde_net_arch, use_expln, squash_output, features_extractor_class, features_extractor_kwargs, normalize_images, optimizer_class, optimizer_kwargs)
458 self.activation_fn = activation_fn
459 self.ortho_init = ortho_init
--> 461 self.features_extractor = features_extractor_class(self.observation_space, **self.features_extractor_kwargs)
462 self.features_dim = self.features_extractor.features_dim
464 self.normalize_images = normalize_images
File E:\Anaconda\lib\site-packages\stable_baselines3\common\torch_layers.py:258, in CombinedExtractor.__init__(self, observation_space, cnn_output_dim)
255 extractors = {}
257 total_concat_size = 0
--> 258 for key, subspace in observation_space.spaces.items():
259 if is_image_space(subspace):
260 extractors[key] = NatureCNN(subspace, features_dim=cnn_output_dim)
AttributeError: 'Box' object has no attribute 'spaces'

No such file or directory error when loading hvplot sample data

I run the following hvplot code,
from hvplot.sample_data import us_crime
columns = ['Burglary rate', 'Larceny-theft rate', 'Robbery rate', 'Violent Crime rate']
us_crime.plot.violin(y=columns, group_label='Type of crime', value_label='Rate per 100k', invert=True)
but get No such file or directory error, anyone know what might be wrong ? Thanks
FileNotFoundError Traceback (most recent call last)
<ipython-input-30-6e0bc6b3a875> in <module>
----> 1 from hvplot.sample_data import us_crime
2
3 columns = ['Burglary rate', 'Larceny-theft rate', 'Robbery rate', 'Violent Crime rate']
4
5
/opt/conda/lib/python3.7/site-packages/hvplot/sample_data.py in <module>
19
20 # Load catalogue
---> 21 catalogue = open_catalog(_cat_path)
22
23 # Add catalogue entries to namespace
/opt/conda/lib/python3.7/site-packages/intake/__init__.py in open_catalog(uri, **kwargs)
160 raise ValueError('Unknown catalog driver (%s), supply one of: %s'
161 % (driver, list(sorted(registry))))
--> 162 return registry[driver](uri, **kwargs)
163
164
/opt/conda/lib/python3.7/site-packages/intake/catalog/local.py in __init__(self, path, autoreload, **kwargs)
550 self.autoreload = autoreload # set this to False if don't want reloads
551 self.filesystem = kwargs.pop('fs', None)
--> 552 super(YAMLFileCatalog, self).__init__(**kwargs)
553
554 def _load(self, reload=False):
/opt/conda/lib/python3.7/site-packages/intake/catalog/base.py in __init__(self, name, description, metadata, auth, ttl, getenv, getshell, persist_mode, storage_options, *args)
111 self.updated = time.time()
112 self._entries = self._make_entries_container()
--> 113 self.force_reload()
114
115 #classmethod
/opt/conda/lib/python3.7/site-packages/intake/catalog/base.py in force_reload(self)
168 def force_reload(self):
169 """Imperative reload data now"""
--> 170 self._load()
171 self.updated = time.time()
172
/opt/conda/lib/python3.7/site-packages/intake/catalog/local.py in _load(self, reload)
575 self._dir = get_dir(self.path)
576
--> 577 with file_open as f:
578 text = f.read().decode()
579 if "!template " in text:
/opt/conda/lib/python3.7/site-packages/fsspec/core.py in __enter__(self)
100 mode = self.mode.replace("t", "").replace("b", "") + "b"
101
--> 102 f = self.fs.open(self.path, mode=mode)
103
104 self.fobjects = [f]
/opt/conda/lib/python3.7/site-packages/fsspec/spec.py in open(self, path, mode, block_size, cache_options, **kwargs)
934 autocommit=ac,
935 cache_options=cache_options,
--> 936 **kwargs
937 )
938 if not ac:
/opt/conda/lib/python3.7/site-packages/fsspec/implementations/local.py in _open(self, path, mode, block_size, **kwargs)
115 if self.auto_mkdir and "w" in mode:
116 self.makedirs(self._parent(path), exist_ok=True)
--> 117 return LocalFileOpener(path, mode, fs=self, **kwargs)
118
119 def touch(self, path, **kwargs):
/opt/conda/lib/python3.7/site-packages/fsspec/implementations/local.py in __init__(self, path, mode, autocommit, fs, **kwargs)
197 self.autocommit = autocommit
198 self.blocksize = io.DEFAULT_BUFFER_SIZE
--> 199 self._open()
200
201 def _open(self):
/opt/conda/lib/python3.7/site-packages/fsspec/implementations/local.py in _open(self)
202 if self.f is None or self.f.closed:
203 if self.autocommit or "w" not in self.mode:
--> 204 self.f = open(self.path, mode=self.mode)
205 else:
206 # TODO: check if path is writable?
FileNotFoundError: [Errno 2] No such file or directory: '/opt/conda/lib/python3.7/site-packages/hvplot/../examples/datasets.yaml'
ERROR
Took 1 sec. Last updated by anonymous at March 12 2021, 12:11:24 PM.

NotImplementedError: Failed in nopython mode pipeline. Use of unknown opcode MAP_ADD at line 116 of <ipython-input-287-147d4798a88b>

I try to launch a code with Numba and I get errors.
What I want to do is to compute the cosine similarity with a cosinus_sparse function. This class method I use in the search class method, then I call search in the results method. Although I added the #jit decorator before each method I have this implementation error that appears.
Here is my code:
import numpy as np
from numba import jit
from sklearn.feature_extraction.text import CountVectorizer, TfidfVectorizer
import pandas as pd
import math
class Search:
def __init__(self, corpus, method='XTERM', stop_words='english', max_df=1.0, min_df=1, max_features=None):
self.corpus = corpus
self.method = method
self.stop_words = stop_words
self.max_df = max_df
self.min_df = min_df
self.max_features = max_features
self.vectorization()
self.get_shape()
self.features_names = self.bag_of_word.get_feature_names()
def vectorization(self):
if self.method == 'XTERM':
self.bag_of_word = CountVectorizer(stop_words=self.stop_words,
max_df=self.max_df, min_df=self.min_df,
max_features=self.max_features)
self.corpus_vectorized = self.bag_of_word.fit_transform(self.corpus)
elif self.method == 'TFxIDF':
self.bag_of_word = TfidfVectorizer(stop_words=self.stop_words,
max_df=self.max_df, min_df=self.min_df,
max_features=self.max_features)
self.corpus_vectorized = self.bag_of_word.fit_transform(self.corpus)
else:
raise MethodError('Method provided is not valid')
def get_shape(self):
self.n_docs, self.n_terms = self.corpus_vectorized.shape
def get_query(self, query):
self.indexes = [self.features_names.index(q) for q in query if q in self.features_names]
self.query_vec = np.zeros(self.n_terms)
self.query_vec[self.indexes] = 1
#staticmethod
#jit(nopython=True)
def cosinus_sparse(i, j):
num = i.dot(j)
spars = i * i.transpose()
den = math.sqrt(spars[0, 0]) * math.sqrt(sum(j * j))
if (den > 0):
return int(num) / den
else:
return 0
#jit(nopython=True)
def search(self, q) -> dict:
cc = {i: self.cosinus_sparse(self.corpus_vectorized[i, :], q) for i in range(self.n_docs)}
cc = sorted(cc.items(), key=lambda x: x[1], reverse=True)
return cc
#jit
def get_result(self) -> list:
self.result = self.search(self.query_vec)
def result_announcer(self):
self.search_lenght = len([i for i in self.result if i[1] > 0])
print('{} documents linked to your query where found'.format(search_lenght))
def verif_query_vec(self, query):
if int(sum(self.query_vec)) != len(query):
raise QueryError('Error in query or query_vec')
def processing(self, query):
try:
self.get_query(query)
self.verif_query_vec(query)
self.get_result()
except NameError:
self.vectorisation()
self.get_shape()
self.get_feature_names()
self.get_query(query)
self.verif_query_vec(query)
self.get_result()
import ipywidgets as widgets
from IPython.display import display
text = widgets.Text(
value='',
placeholder='Type words',
description='String:',
disabled=False
)
method_radio = widgets.RadioButtons(
options=['XTERM', 'TFxIDF'],
# value='TF',
description='Method:',
disabled=False
)
submit = widgets.Button(description = 'Search')
display(widgets.VBox([text, radio, submit]))
def handle_submit(sender):
global query
query = text.value.lower().split(' ')
method = method_radio.value
# instentiation de l'objet de recherche
global search_obj
search_obj = Search(corpus=corpus, method=method, )
search_obj.processing(query)
submit.on_click(handle_submit)
Here is the error
NotImplementedError Traceback (most recent call last)
<ipython-input-288-025a488daa60> in handle_submit(sender)
27 global search_obj
28 search_obj = Search(corpus=corpus, method=method, )
---> 29 search_obj.processing(query)
30
31 submit.on_click(handle_submit)
<ipython-input-287-147d4798a88b> in processing(self, query)
167 self.get_query(query)
168 self.verif_query_vec(query)
--> 169 self.get_result()
170
171 except NameError:
~\Anaconda3\lib\site-packages\numba\dispatcher.py in _compile_for_args(self, *args, **kws)
365 e.patch_message(''.join(e.args) + help_msg)
366 # ignore the FULL_TRACEBACKS config, this needs reporting!
--> 367 raise e
368
369 def inspect_llvm(self, signature=None):
~\Anaconda3\lib\site-packages\numba\dispatcher.py in _compile_for_args(self, *args, **kws)
322 argtypes.append(self.typeof_pyval(a))
323 try:
--> 324 return self.compile(tuple(argtypes))
325 except errors.TypingError as e:
326 # Intercept typing error that may be due to an argument
~\Anaconda3\lib\site-packages\numba\compiler_lock.py in _acquire_compile_lock(*args, **kwargs)
30 def _acquire_compile_lock(*args, **kwargs):
31 with self:
---> 32 return func(*args, **kwargs)
33 return _acquire_compile_lock
34
~\Anaconda3\lib\site-packages\numba\dispatcher.py in compile(self, sig)
653
654 self._cache_misses[sig] += 1
--> 655 cres = self._compiler.compile(args, return_type)
656 self.add_overload(cres)
657 self._cache.save_overload(sig, cres)
~\Anaconda3\lib\site-packages\numba\dispatcher.py in compile(self, args, return_type)
80 args=args, return_type=return_type,
81 flags=flags, locals=self.locals,
---> 82 pipeline_class=self.pipeline_class)
83 # Check typing error if object mode is used
84 if cres.typing_error is not None and not flags.enable_pyobject:
~\Anaconda3\lib\site-packages\numba\compiler.py in compile_extra(typingctx, targetctx, func, args, return_type, flags, locals, library, pipeline_class)
924 pipeline = pipeline_class(typingctx, targetctx, library,
925 args, return_type, flags, locals)
--> 926 return pipeline.compile_extra(func)
927
928
~\Anaconda3\lib\site-packages\numba\compiler.py in compile_extra(self, func)
372 self.lifted = ()
373 self.lifted_from = None
--> 374 return self._compile_bytecode()
375
376 def compile_ir(self, func_ir, lifted=(), lifted_from=None):
~\Anaconda3\lib\site-packages\numba\compiler.py in _compile_bytecode(self)
855 """
856 assert self.func_ir is None
--> 857 return self._compile_core()
858
859 def _compile_ir(self):
~\Anaconda3\lib\site-packages\numba\compiler.py in _compile_core(self)
842 self.define_pipelines(pm)
843 pm.finalize()
--> 844 res = pm.run(self.status)
845 if res is not None:
846 # Early pipeline completion
~\Anaconda3\lib\site-packages\numba\compiler_lock.py in _acquire_compile_lock(*args, **kwargs)
30 def _acquire_compile_lock(*args, **kwargs):
31 with self:
---> 32 return func(*args, **kwargs)
33 return _acquire_compile_lock
34
~\Anaconda3\lib\site-packages\numba\compiler.py in run(self, status)
253 # No more fallback pipelines?
254 if is_final_pipeline:
--> 255 raise patched_exception
256 # Go to next fallback pipeline
257 else:
~\Anaconda3\lib\site-packages\numba\compiler.py in run(self, status)
244 try:
245 event(stage_name)
--> 246 stage()
247 except _EarlyPipelineCompletion as e:
248 return e.result
~\Anaconda3\lib\site-packages\numba\compiler.py in stage_inline_pass(self)
582 self.flags.auto_parallel,
583 self.parfor_diagnostics.replaced_fns)
--> 584 inline_pass.run()
585 # Remove all Dels, and re-run postproc
586 post_proc = postproc.PostProcessor(self.func_ir)
~\Anaconda3\lib\site-packages\numba\inline_closurecall.py in run(self)
75
76 if guard(self._inline_closure,
---> 77 work_list, block, i, func_def):
78 modified = True
79 break # because block structure changed
~\Anaconda3\lib\site-packages\numba\ir_utils.py in guard(func, *args, **kwargs)
1358 """
1359 try:
-> 1360 return func(*args, **kwargs)
1361 except GuardException:
1362 return None
~\Anaconda3\lib\site-packages\numba\inline_closurecall.py in _inline_closure(self, work_list, block, i, func_def)
212 inline_closure_call(self.func_ir,
213 self.func_ir.func_id.func.__globals__,
--> 214 block, i, func_def, work_list=work_list)
215 return True
216
~\Anaconda3\lib\site-packages\numba\inline_closurecall.py in inline_closure_call(func_ir, glbls, block, i, callee, typingctx, arg_typs, typemap, calltypes, work_list)
253 callee_closure = callee.closure if hasattr(callee, 'closure') else callee.__closure__
254 # first, get the IR of the callee
--> 255 callee_ir = get_ir_of_code(glbls, callee_code)
256 callee_blocks = callee_ir.blocks
257
~\Anaconda3\lib\site-packages\numba\ir_utils.py in get_ir_of_code(glbls, fcode)
1572 f.__name__ = fcode.co_name
1573 from numba import compiler
-> 1574 ir = compiler.run_frontend(f)
1575 # we need to run the before inference rewrite pass to normalize the IR
1576 # XXX: check rewrite pass flag?
~\Anaconda3\lib\site-packages\numba\compiler.py in run_frontend(func)
168 interp = interpreter.Interpreter(func_id)
169 bc = bytecode.ByteCode(func_id=func_id)
--> 170 func_ir = interp.interpret(bc)
171 post_proc = postproc.PostProcessor(func_ir)
172 post_proc.run()
~\Anaconda3\lib\site-packages\numba\interpreter.py in interpret(self, bytecode)
101 # Data flow analysis
102 self.dfa = dataflow.DataFlowAnalysis(self.cfa)
--> 103 self.dfa.run()
104
105 # Temp states during interpretation
~\Anaconda3\lib\site-packages\numba\dataflow.py in run(self)
26 def run(self):
27 for blk in self.cfa.iterliveblocks():
---> 28 self.infos[blk.offset] = self.run_on_block(blk)
29
30 def run_on_block(self, blk):
~\Anaconda3\lib\site-packages\numba\dataflow.py in run_on_block(self, blk)
76 for offset in blk:
77 inst = self.bytecode[offset]
---> 78 self.dispatch(info, inst)
79 return info
80
~\Anaconda3\lib\site-packages\numba\dataflow.py in dispatch(self, info, inst)
86 fname = "op_%s" % inst.opname.replace('+', '_')
87 fn = getattr(self, fname, self.handle_unknown_opcode)
---> 88 fn(info, inst)
89
90 def handle_unknown_opcode(self, info, inst):
~\Anaconda3\lib\site-packages\numba\dataflow.py in handle_unknown_opcode(self, info, inst)
91 msg = "Use of unknown opcode {} at line {} of {}"
92 raise NotImplementedError(msg.format(inst.opname, inst.lineno,
---> 93 self.bytecode.func_id.filename))
94
95 def dup_topx(self, info, inst, count):
NotImplementedError: Failed in nopython mode pipeline (step: inline calls to locally defined closures)
Use of unknown opcode MAP_ADD at line 116 of <ipython-input-287-147d4798a88b>
How do I fix this error?
Thanks a lot for your help.

pandas_profiling TypeError when using HTML format

I follow the pandas_profiling document script, but this problem always arises.
My dataset is the boston from sklearn.
I have the report, but without the features of an html version:
profile2 = ProfileReport(data, title="Relatório DATASET -data-", html={'style': {'full_width': True}}, sort="None")
The image below refers to this code:
from pandas_profiling import ProfileReport
profile = ProfileReport(data, title='Pandas Profiling Report', explorative=True)
[![enter image description here][1]][1]
My version of pandas_profiling
[![enter image description here][2]][2]
I don't have the problem related above if I use this code:
profile = ProfileReport (data)
UPDATE:
Uninstalled the previous version and got the new one (2.9.0), but this problems happens:
Summarize dataset: 75%
21/28 [00:07<00:02, 2.84it/s, Get scatter matrix]
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
C:\ProgramData\Anaconda3\lib\site-packages\IPython\core\formatters.py in __call__(self, obj)
343 method = get_real_method(obj, self.print_method)
344 if method is not None:
--> 345 return method()
346 return None
347 else:
C:\ProgramData\Anaconda3\lib\site-packages\pandas_profiling\profile_report.py in _repr_html_(self)
407 def _repr_html_(self):
408 """The ipython notebook widgets user interface gets called by the jupyter notebook."""
--> 409 self.to_notebook_iframe()
410
411 def __repr__(self):
C:\ProgramData\Anaconda3\lib\site-packages\pandas_profiling\profile_report.py in to_notebook_iframe(self)
387 with warnings.catch_warnings():
388 warnings.simplefilter("ignore")
--> 389 display(get_notebook_iframe(self))
390
391 def to_widgets(self):
C:\ProgramData\Anaconda3\lib\site-packages\pandas_profiling\report\presentation\flavours\widget\notebook.py in get_notebook_iframe(profile)
63 output = get_notebook_iframe_src(profile)
64 elif attribute == "srcdoc":
---> 65 output = get_notebook_iframe_srcdoc(profile)
66 else:
67 raise ValueError(
C:\ProgramData\Anaconda3\lib\site-packages\pandas_profiling\report\presentation\flavours\widget\notebook.py in get_notebook_iframe_srcdoc(profile)
21 width = config["notebook"]["iframe"]["width"].get(str)
22 height = config["notebook"]["iframe"]["height"].get(str)
---> 23 src = html.escape(profile.to_html())
24
25 iframe = f'<iframe width="{width}" height="{height}" srcdoc="{src}" frameborder="0" allowfullscreen></iframe>'
C:\ProgramData\Anaconda3\lib\site-packages\pandas_profiling\profile_report.py in to_html(self)
357
358 """
--> 359 return self.html
360
361 def to_json(self) -> str:
C:\ProgramData\Anaconda3\lib\site-packages\pandas_profiling\profile_report.py in html(self)
177 def html(self):
178 if self._html is None:
--> 179 self._html = self._render_html()
180 return self._html
181
C:\ProgramData\Anaconda3\lib\site-packages\pandas_profiling\profile_report.py in _render_html(self)
284 from pandas_profiling.report.presentation.flavours import HTMLReport
285
--> 286 report = self.report
287
288 disable_progress_bar = not config["progress_bar"].get(bool)
C:\ProgramData\Anaconda3\lib\site-packages\pandas_profiling\profile_report.py in report(self)
171 def report(self):
172 if self._report is None:
--> 173 self._report = get_report_structure(self.description_set)
174 return self._report
175
C:\ProgramData\Anaconda3\lib\site-packages\pandas_profiling\profile_report.py in description_set(self)
152 def description_set(self):
153 if self._description_set is None:
--> 154 self._description_set = describe_df(self.title, self.df, self._sample)
155 return self._description_set
156
C:\ProgramData\Anaconda3\lib\site-packages\pandas_profiling\model\describe.py in describe(title, df, sample)
100 # Scatter matrix
101 pbar.set_postfix_str("Get scatter matrix")
--> 102 scatter_matrix = get_scatter_matrix(df, variables)
103 pbar.update()
104
C:\ProgramData\Anaconda3\lib\site-packages\pandas_profiling\model\summary.py in get_scatter_matrix(df, variables)
696 for y in continuous_variables:
697 if x in continuous_variables:
--> 698 scatter_matrix[x][y] = scatter_pairwise(df[x], df[y], x, y)
699 else:
700 scatter_matrix = {}
C:\ProgramData\Anaconda3\lib\contextlib.py in inner(*args, **kwds)
71 #wraps(func)
72 def inner(*args, **kwds):
---> 73 with self._recreate_cm():
74 return func(*args, **kwds)
75 return inner
C:\ProgramData\Anaconda3\lib\contextlib.py in __enter__(self)
110 del self.args, self.kwds, self.func
111 try:
--> 112 return next(self.gen)
113 except StopIteration:
114 raise RuntimeError("generator didn't yield") from None
C:\ProgramData\Anaconda3\lib\site-packages\pandas_profiling\visualisation\context.py in manage_matplotlib_context()
77 register_matplotlib_converters()
78 matplotlib.rcParams.update(customRcParams)
---> 79 sns.set_style(style="white")
80 yield
81 finally:
AttributeError: module 'seaborn' has no attribute 'set_style'
The solution was unistall / reinstall the Anaconda and the pandas-profiling. Probably some version issue as suggested by Paul H on the comments.

what is the problem ?: application.connect() error

I am a beginner developer who started to study automation by using pywinauto.
An overflow error occurs when using application.connect () to connect to an already open program.
But application.start() works fine....
Please help me if someone know this part.
The source code and error contents are as follows.
Source code:
import pywinauto
app = pywinauto.application.Application()
app.connect(title_re='Calculator')
Error:
OverflowError Traceback (most recent call last)
in
1 import pywinauto
2 app = pywinauto.application.Application()
----> 3 app.connect(title_re='Calculator')
d:\Anaconda3\lib\site-packages\pywinauto\application.py in connect(self, **kwargs)
972 ).process_id
973 else:
--> 974 self.process = findwindows.find_element(**kwargs).process_id
975 connected = True
976
d:\Anaconda3\lib\site-packages\pywinauto\findwindows.py in find_element(**kwargs)
82 so please see :py:func:find_elements for the full parameters description.
83 """
---> 84 elements = find_elements(**kwargs)
85
86 if not elements:
d:\Anaconda3\lib\site-packages\pywinauto\findwindows.py in find_elements(class_name, class_name_re, parent, process, title, title_re, top_level_only, visible_only, enabled_only, best_match, handle, ctrl_index, found_index, predicate_func, active_only, control_id, control_type, auto_id, framework_id, backend, depth)
279 return title_regex.match(t)
280 return False
--> 281 elements = [elem for elem in elements if _title_match(elem)]
282
283 if visible_only:
d:\Anaconda3\lib\site-packages\pywinauto\findwindows.py in (.0)
279 return title_regex.match(t)
280 return False
--> 281 elements = [elem for elem in elements if _title_match(elem)]
282
283 if visible_only:
d:\Anaconda3\lib\site-packages\pywinauto\findwindows.py in _title_match(w)
275 def _title_match(w):
276 """Match a window title to the regexp"""
--> 277 t = w.rich_text
278 if t is not None:
279 return title_regex.match(t)
d:\Anaconda3\lib\site-packages\pywinauto\win32_element_info.py in rich_text(self)
81 def rich_text(self):
82 """Return the text of the window"""
---> 83 return handleprops.text(self.handle)
84
85 name = rich_text
d:\Anaconda3\lib\site-packages\pywinauto\handleprops.py in text(handle)
86 length += 1
87
---> 88 buffer_ = ctypes.create_unicode_buffer(length)
89
90 ret = win32functions.SendMessage(
d:\Anaconda3\lib\ctypes_init_.py in create_unicode_buffer(init, size)
286 return buf
287 elif isinstance(init, int):
--> 288 buftype = c_wchar * init
289 buf = buftype()
290 return buf
OverflowError: cannot fit 'int' into an index-sized integer
import pywinauto
app = pywinauto.Application(backend='uia').start('calc.exe')
try this if you are having problem you have to say the backennd is a uia it working fine for me.

Categories

Resources