I am using python 3.8 in spyder3. I am getting an error while doing:
mp=MPRester('api key')
data = mp.query(criteria={}, properties=['task_id']) #this line raises error
The error is :
NameError: name '**IProgress**' is not defined.
During handling of the above exception, another exception occurred:
ImportError: **FloatProgress** not found. Please update jupyter and ipywidgets.
But I'm not working with Jupyter notebook and ipywidgets is updated. This problem doesn't happen while working in Google collab.
Installing these two worked for me:
pip install ipywidgets IProgress
I am not answering the error but showing a worked script for me. Using the following approach might help.
from pymatgen import MPRester
api = MPRester("your key")
# criteria you want
criteria={"elements":{"$all": ["O"]}, "nelements":{'$lt':4}}
# properties you want
properties = ["pretty_formula", "cif", "material_id"]
c = api.query(criteria=criteria,properties=properties)
Related
I have used the below program to get the maximum and minimum value in a dictionary. But, there is an type error.
I am running the below code on Jupyter notebook and getting the type error as the 'dict.keys' object is not callable. same code runs successfully on the pycharm.
Please advise me what changes should I make so that the code runs successfully on the jupyter notebook?
what is wrong in my code? Code run on JupyterNBcode run on Pycharm successfully
I have tested your program in Jupyter Notebook and the code is working just fine. Maybe you check for any typos. Hope this help
Code snippet run on jupyter notebook
Yup I can run your code perfectly too. Please try to simplify it like below.
It looks better too.
my_dict = {'x':500, 'y':5874, 'z': 560}
key_max = max(my_dict, key = my_dict.get)
key_min = min(my_dict, key = my_dict.get)
print('Maximum Value: ',my_dict[key_max])
print('Minimum Value: ',my_dict[key_min])
Here You can see a Colab code. I basically try to run those codes but I get this error.
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-16-1b48c937269f> in <module>()
----> 1 macrodemos.ARMA()
3 frames
/usr/local/lib/python3.7/dist-packages/dash/_utils.py in __setitem__(self, key, val)
156
157 # pylint: disable=inconsistent-return-statements
--> 158 def first(self, *names):
159 for name in names:
160 value = self.get(name)
AttributeError: ('Read-only: can only be set in the Dash constructor or during init_app()', 'requests_pathname_prefix')
I have no idea about this actually and I am not an expert. Could you please explain the problem? and a solution if you have any. Thanks
It appears there is some issue with the latest version of the package.
Using the following version of the packages appears to work well.
Notebook with changes, for your convenience:
https://colab.research.google.com/drive/1WyPr2p2nXmrNhjqJXl7hKaHtOocP731S?usp=sharing
Explanation:
While installing the packages, simple use:
!pip install macrodemos --upgrade
!pip install -q dash==1.19.0
This will replace the version of dash used to an older one that works, Here is a screenshot for your reference:
Screenshot 1
I am a newbie and I appreciate your feedback about whether this is helpful or not.
Thanks in advance. :)
I was able to fix this error by following the recommendations in the error message pasted here for reference,
AttributeError: ('Read-only: can only be set in the Dash constructor or during init_app()', 'requests_pathname_prefix')
The solution is to only set the Dash config when you first initialize the app application instead of using app.config.update according to the new version of Dash.
So instead of something like this which is trying to update a read-only variable,
app.config.update({
'requests_pathname_prefix': '/dash/' # wrong, will cause read-only error
})
You could do,
app = dash.Dash(
:
requests_pathname_prefix='/dash/')
Which sets those variables when it originally was defined so there will be no read-only error.
This answer might not fully address the original poster's concerns because after looking at the Colab notebook, the library of concern is macrodemos which needs to be updated to be compatible with the newest version of Dash.
I was working on something an I this is actually my first time so things are not that clear for me yet, I ran this code :
pip install nipype
from nipype import Node, Workflow
from nipype.interfaces.fsl import SliceTimer, MCFLIRT, Smooth
slicetimer = Node(SliceTimer(index_dir=False,
interleaved=True,
time_repetition=2.5),
name="slicetimer")
mcflirt = Node(MCFLIRT(mean_vol=True,
save_plots=True),
name="mcflirt")
smooth = Node(Smooth(fwhm=4), name="smooth")
preproc01 = Workflow(name='preproc01', base_dir="dir_path")
preproc01.connect([(slicetimer, mcflirt, [('slice_time_corrected_file', 'in_file')]),
(mcflirt, smooth, [('out_file', 'in_file')])])
slicetimer.inputs.in_file = "file_path"
preproc01.run('MultiProc')
This is the error shown when I run the last line of code :
"Could not import plugin module: nipype.pipeline.plugins"
There is one more problem :
When I try to run this code :
preproc01.write_graph(graph2use='orig')
This is the error message shown :
'No command "dot" found on host. Please check that the corresponding package is installed.'
please if anyone knows the solution help me out.
BTW I an doing this from a video series, here is the link :https://www.youtube.com/watch?v=4FVGn8vodkc&t=4414s
Nipype showcase section.
I am using TableauServerClient to update the owner of a report on Tableau server. Here is my simple code:
Try:
single_workbook = server.workbooks.get_by_id(workbook_id) #default ownerid of fsg_tableaureporting
single_workbook.owner_id = ownerid
if (server.workbooks.update(single_workbook)):
print('Workbook owner has been updated successfully')
else:
print('Workbook owner could not be updated. Please try again. Exiting..')
except Exception as e:
print('Exceptions occured while changing the owner.')
print(e)
I get the exception at the statement server.workbooks.update(single_workbook).
Anyone have any suggestions?
Python: 3.7.3
TSC: 0.8.1
Tableau server: 2019.1.3 (20191.19.0417.1429) 64-bit Windows
I just encountered the same issue. Looking at logs (C:\Tableau Server\data\tabsvc\logs\vizportal\vizportal-0.log for Windows), I see the error:
Caused by: com.sun.istack.internal.SAXParseException2; lineNumber: 1; columnNumber: 238; unexpected element (uri:"", local:"dataAccelerationConfig"). Expected elements are <{}owner>,<{}site>,<{}project>,<{}connections>,<{}connectionCredentials>,<{}views>,<{}tags>
The error specifically happens at generating the XML here:
https://github.com/tableau/server-client-python/blob/188be71e0fbe9d87ac36628af21d2f63af32d020/tableauserverclient/server/endpoint/workbooks_endpoint.py#L103
Upon checking whats happening in that request, I see its adding a section in xml for data_acceleration_config which I think is a new feature starting in very recent versions, 2019.4 maybe:
https://github.com/tableau/server-client-python/blob/188be71e0fbe9d87ac36628af21d2f63af32d020/tableauserverclient/server/request_factory.py#L485
Unfortunately the API doesnt handle this properly, yet! I am trying to tweak my code to not generate that xml element; will update again if I get to a solution.
I'm using tableauserverclient version 0.12 and have face the similar issues; However when I downgrade to version 0.10, I didn't encounter this issue when update workbook project.
I'm having a problem running the following chunk of code in Jupyter Notebook:
i=[0,1,2,3]
from eppy.runner import run_functions
for i in i:
OA.Economizer_Control_Type = ECT[i]
idf1.saveas('C:/Users/mdahdolan/Dropbox/Work and Studies/Economizer
Study/Python/1A_Small_Office.idf')
print(OA.Economizer_Control_Type)
idf1.run(verbose='v')
and I'm getting this error:
om/bEI6B.jpg
You have issues with the path in the function saveas(), check that the route is available, exists and you can reach it without privileges ;)