Python: Name "extract_training_sample" is not defined error - python

I am a Python newbie currently looking into Crash Course Ai #5 How to Make an AI read your handwriting (LAB).
Running Step 1.2 gives me *NameError: name 'extract_training_samples' is not defined.
Tried so far: 1) updated pip version to 20.0.2 and installed emnist python package
2) tried an additional line of code: from emnist import extract_training_samples but got a ModuleNotFound error.
Feedback appreciated!

OK, very simple solution!
You just forgot the "s".
I find myself running into that problem all the time when coding. Whenever I run into a Name Error, the first thing I do is check my spelling!
your code:
x, y = extract_training_sample('letters')
the code on the website:
extract_training_samples('letters')
Cheers,

Related

What I get an attribute error from plotly-dash in PYTHON?

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.

Neuroimaging 'nipype ' plugin not working

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.

Error in installing shapes module in Python

Hey Guys I written some code to make a simple hut using turtle and shapes in python but when i am importing the shapes then it is showing me error this is the error
here is my code
import turtle
from shapes import *
# naming the turtle
pen = turtle.Turtle()
# setting up turtle
pen.speed(100)
pen.color(0,0,0)
wn = turtle.Screen()
wn.color(66,202,244)
#start drawing
drawWindow(pen,-95,15,"square")
drawHouse(pen)
drawDoor(pen,-25,-20)
drawBush(pen,120,35)
drawWindow(pen,-10,100,"circle")
drawFence(pen)
drawPath(pen)
drawWindow(pen,-95,100,"square")
drawGrass(pen)
drawCloud(pen,75,160)
drawWindow(pen,75,15,"square")
drawSun(pen,-200,160,70)
drawWindow(pen,180,150,"square")
then i read a solution for this to install "pysal" but when I am installing pysal(pip install pysal) from cmd then it is also showing this error while installing pysal
please resolve it.
The error says no module is named shapes to solve that you need to pip install shapes
There is the code in shapes/__init__.py:
from Shape import Shape
The code works under Python 2 and doesn't work under Python 3. For Python 3 it must be either
from shapes.Shape import Shape
or
from .Shape import Shape
The same problem with other relative imports. The bottom line: the package shapes is Python2-only. Please report the problem or even better send a pull-request to fix it.

python WMI screen brightness adjuster gets error 0x8004100c

I'm currently working on a script that creates a tray icon that allows the user to adjust screen brightness through menu options. The source code, written in python 3.6.8, can be found as a paste HERE. There seems to be an error message coming up when trying to select one of the brightness options, seen HERE. I did some reading and found that the error I'm getting (0x8004100c) refers to a feature or operation not being supported. Are there any workarounds available for this?
Thank you in advance.
code: https://pastebin.com/sLbyE9yb
error: https://pastebin.com/Xs7wHk73
WMI error reference: https://learn.microsoft.com/en-us/windows/win32/wmisdk/wmi-error-constants
gist: https://gist.github.com/imri0t/12e768e3d7e08734b85ae532d56090e1
(also if anyone can let me know if there's a way to keep the script from dying after an action is made it would be appreciated)
modules needed: pip install infi.systray / pip install wmi
code snip that I believe produces the error:
from infi.systray import SysTrayIcon
import wmi
def brightness_50(systray):
'''brightness: 50%'''
b = 50
c = wmi.WMI(namespace='root\\wmi')
br = c.WmiMonitorBrightnessMethods()[0]
br.WmiSetBrightness(3, b) #b will be a precentage / 100
menu = (("brightness: 100%", None, brightness_50))
systray = SysTrayIcon("icon.ico", "brightness", menu)
systray.start()

Issue running energyplus using eppy idf.run()

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 ;)

Categories

Resources